Skip to content

Commit e24f20f

Browse files
authored
Add Python 3.12, Drop Python 3.10 (#1134)
1 parent fdf918c commit e24f20f

10 files changed

Lines changed: 36 additions & 29 deletions

File tree

.github/labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
description: "A breaking change for existing users."
55
- name: "bugfix"
66
color: ee0701
7-
description: "Inconsistencies or issues which will cause a problem for users or implementors."
7+
description: "Inconsistencies or issues which will cause a problem for users or implementers."
88
- name: "documentation"
99
color: 0052cc
1010
description: "Solely about the documentation of the project."

.github/workflows/linting.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010
env:
11-
DEFAULT_PYTHON: "3.10"
11+
DEFAULT_PYTHON: "3.11"
1212

1313
jobs:
1414
codespell:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- published
99

1010
env:
11-
DEFAULT_PYTHON: "3.10"
11+
DEFAULT_PYTHON: "3.11"
1212

1313
jobs:
1414
release:

.github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ on:
88
workflow_dispatch:
99

1010
env:
11-
DEFAULT_PYTHON: "3.10"
11+
DEFAULT_PYTHON: "3.11"
1212

1313
jobs:
1414
pytest:
1515
name: Python ${{ matrix.python }}
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python: ["3.10", "3.11"]
19+
python: ["3.11"]
2020
steps:
2121
- name: ⤵️ Check out code from GitHub
2222
uses: actions/checkout@v4.1.1

.github/workflows/typing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010
env:
11-
DEFAULT_PYTHON: "3.10"
11+
DEFAULT_PYTHON: "3.11"
1212

1313
jobs:
1414
mypy:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ development.
8787

8888
You need at least:
8989

90-
- Python 3.10+
90+
- Python 3.11+
9191
- [Poetry][poetry-install]
9292
- NodeJS 18+ (including NPM)
9393

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ classifiers = [
55
"Framework :: AsyncIO",
66
"Intended Audience :: Developers",
77
"Natural Language :: English",
8-
"Programming Language :: Python :: 3.10",
98
"Programming Language :: Python :: 3.11",
9+
"Programming Language :: Python :: 3.12",
1010
"Programming Language :: Python :: 3",
1111
"Topic :: Software Development :: Libraries :: Python Modules",
1212
]
@@ -29,7 +29,7 @@ aiohttp = ">=3.0.0"
2929
awesomeversion = ">=22.1.0"
3030
backoff = ">=2.2.0"
3131
cachetools = ">=4.0.0"
32-
python = "^3.10"
32+
python = "^3.11"
3333
yarl = ">=1.6.0"
3434

3535
[tool.poetry.urls]
@@ -68,7 +68,7 @@ show_missing = true
6868
# free to run mypy on Windows, Linux, or macOS and get consistent
6969
# results.
7070
platform = "linux"
71-
python_version = "3.10"
71+
python_version = "3.11"
7272

7373
# show error messages from unrelated files
7474
follow_imports = "normal"

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ sonar.sourceEncoding=UTF-8
1313
sonar.sources=src
1414
sonar.tests=tests
1515

16-
sonar.python.version=3.10, 3.11
16+
sonar.python.version=3.11, 3.12
1717
sonar.python.coverage.reportPaths=coverage.xml

src/wled/models.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class Segment:
130130
stop: int
131131

132132
@staticmethod
133+
# pylint: disable-next=too-many-arguments
133134
def from_dict( # noqa: PLR0913
134135
segment_id: int,
135136
data: dict[str, Any],
@@ -665,11 +666,11 @@ def from_dict(
665666
class Device:
666667
"""Object holding all information of WLED."""
667668

668-
effects: list[Effect] = []
669+
effects: list[Effect]
669670
info: Info
670-
palettes: list[Palette] = []
671-
playlists: list[Playlist] = []
672-
presets: list[Preset] = []
671+
palettes: list[Palette]
672+
playlists: list[Playlist]
673+
presets: list[Preset]
673674
state: State
674675

675676
def __init__(self, data: dict[str, Any]) -> None:
@@ -684,6 +685,11 @@ def __init__(self, data: dict[str, Any]) -> None:
684685
WLEDError: In case the given API response is incomplete in a way
685686
that a Device object cannot be constructed from it.
686687
"""
688+
self.effects = []
689+
self.palettes = []
690+
self.playlists = []
691+
self.presets = []
692+
687693
# Check if all elements are in the passed dict, else raise an Error
688694
if any(
689695
k not in data and data[k] is not None

src/wled/wled.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import socket
77
from contextlib import suppress
88
from dataclasses import dataclass
9-
from typing import TYPE_CHECKING, Any
9+
from typing import TYPE_CHECKING, Any, Self
1010

1111
import aiohttp
1212
import async_timeout
@@ -198,11 +198,11 @@ async def request(
198198
response.close()
199199

200200
if content_type == "application/json":
201-
raise WLEDError( # noqa: TRY301
201+
raise WLEDError(
202202
response.status,
203203
json.loads(contents.decode("utf8")),
204204
)
205-
raise WLEDError( # noqa: TRY301
205+
raise WLEDError(
206206
response.status,
207207
{"message": contents.decode("utf8")},
208208
)
@@ -367,7 +367,7 @@ async def master(
367367

368368
await self.request("/json/state", method="POST", data=state)
369369

370-
# pylint: disable=too-many-locals, too-many-branches
370+
# pylint: disable=too-many-locals, too-many-branches, too-many-arguments
371371
async def segment( # noqa: PLR0912, PLR0913
372372
self,
373373
segment_id: int,
@@ -689,14 +689,15 @@ async def upgrade(self, *, version: str | AwesomeVersion) -> None:
689689
)
690690

691691
try:
692-
async with async_timeout.timeout(self.request_timeout * 10):
693-
async with self.session.get(
694-
download_url,
695-
raise_for_status=True,
696-
) as download:
697-
form = aiohttp.FormData()
698-
form.add_field("file", await download.read(), filename=update_file)
699-
await self.session.post(url, data=form)
692+
async with async_timeout.timeout(
693+
self.request_timeout * 10,
694+
), self.session.get(
695+
download_url,
696+
raise_for_status=True,
697+
) as download:
698+
form = aiohttp.FormData()
699+
form.add_field("file", await download.read(), filename=update_file)
700+
await self.session.post(url, data=form)
700701
except asyncio.TimeoutError as exception:
701702
msg = "Timeout occurred while fetching WLED version information from GitHub"
702703
raise WLEDConnectionTimeoutError(msg) from exception
@@ -804,7 +805,7 @@ async def close(self) -> None:
804805
if self.session and self._close_session:
805806
await self.session.close()
806807

807-
async def __aenter__(self) -> WLED:
808+
async def __aenter__(self) -> Self:
808809
"""Async enter.
809810
810811
Returns
@@ -813,7 +814,7 @@ async def __aenter__(self) -> WLED:
813814
"""
814815
return self
815816

816-
async def __aexit__(self, *_exc_info: Any) -> None:
817+
async def __aexit__(self, *_exc_info: object) -> None:
817818
"""Async exit.
818819
819820
Args:

0 commit comments

Comments
 (0)