Skip to content

Commit

Permalink
require Python 3.11 and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jschlyter committed Dec 4, 2024
1 parent 0ccc8f8 commit aacf616
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
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"
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

0 comments on commit aacf616

Please sign in to comment.