Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Python 3.11 and lint #44

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: check-yaml
- id: check-json
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.8.1
hooks:
- id: ruff
- id: ruff-format
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ repository = "https://github.com/jschlyter/ttls"
ttls = "ttls.cli:main"

[tool.poetry.dependencies]
python = "^3.9"
python = "^3.11"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Breaking change: Python version requirement increased from 3.9 to 3.11 without proper documentation

The change increases the minimum Python version from 3.9 to 3.11, which is a breaking change. However:

  • No CHANGELOG.md file exists to document this significant change
  • The version bump from 1.9.0 is not following semver (should be 2.0.0 for breaking changes)
  • No upgrade documentation is provided

Required actions:

  • Create a CHANGELOG.md file documenting the Python version requirement change
  • Bump version to 2.0.0 to reflect the breaking change
  • Add upgrade instructions for users on Python 3.9-3.10
🔗 Analysis chain

Consider the impact of requiring Python 3.11.

This is a breaking change that requires users to upgrade their Python version. Consider:

  1. Adding a changelog entry
  2. Incrementing the major version number
  3. Documenting the upgrade path
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there's a CHANGELOG.md file and if it mentions Python 3.11
fd -t f "CHANGELOG.md" -x grep -l "Python 3.11" {} \;

Length of output: 56


Script:

#!/bin/bash
# Check if CHANGELOG.md exists
fd -t f "CHANGELOG.md"

# Check current version in pyproject.toml
grep "version" pyproject.toml

# Check previous Python version requirement
git show HEAD^:pyproject.toml | grep "python ="

Length of output: 138

aiohttp = "^3.8.5"

[tool.poetry.group.dev.dependencies]
pytest = "^8"
aiounittest = "^1.4.2"
ruff = "^0.6.9"
ruff = ">=0.8.1"
pytest-ruff = "^0.4.1"

[build-system]
Expand Down
10 changes: 4 additions & 6 deletions ttls/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

from __future__ import annotations

import base64
import logging
import os
import socket
import time
from itertools import cycle, islice
from typing import Any, Callable, Optional, Tuple
from typing import Any, Callable

from aiohttp import (
ClientResponseError,
Expand All @@ -49,7 +47,7 @@
_LOGGER = logging.getLogger(__name__)

TwinklyFrame = list[TwinklyColourTuple]
TwinklyResult = Optional[dict]
TwinklyResult = dict | None


TWINKLY_MODES = [
Expand Down Expand Up @@ -419,7 +417,7 @@ async def set_static_colour(
await self.interview()
if isinstance(colour, list):
colour = colour[0]
if isinstance(colour, Tuple):
if isinstance(colour, tuple):
colour = TwinklyColour.from_twinkly_tuple(colour)
if await self.get_api_version() == 1:
await self._post(
Expand All @@ -440,7 +438,7 @@ async def set_cycle_colours(
) -> None:
if isinstance(colour, TwinklyColour):
sequence = [colour.as_twinkly_tuple()]
elif isinstance(colour, Tuple):
elif isinstance(colour, tuple):
sequence = [colour]
elif isinstance(colour, list):
sequence = [c.as_twinkly_tuple() for c in colour] if isinstance(colour[0], TwinklyColour) else colour
Expand Down
9 changes: 4 additions & 5 deletions ttls/colours.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from dataclasses import dataclass
from typing import Dict, Optional, Tuple, Union

ColourDict = Dict[str, int]
ColourTuple = Union[Tuple[int, int, int], Tuple[int, int, int, int]]
TwinklyColourTuple = Union[Tuple[int, int, int], Tuple[int, int, int, int]]
ColourDict = dict[str, int]
ColourTuple = tuple[int, int, int] | tuple[int, int, int, int]
TwinklyColourTuple = tuple[int, int, int] | tuple[int, int, int, int]


@dataclass(frozen=True)
class TwinklyColour:
red: int
green: int
blue: int
white: Optional[int] = None
white: int | None = None

def as_twinkly_tuple(self) -> TwinklyColourTuple:
"""Convert TwinklyColour to a tuple as used by Twinkly: (R,G,B) or (W,R,G,B)"""
Expand Down
Loading