Skip to content

Commit c47e72c

Browse files
authored
Prepare for Python 3.12, 3.13 (#39)
- CI previously tested only on Python 3.11; updated to test 3.11, 3.12, 3.13. - asyncio.get_event_loop() behavior changed (Py 3.12+) - In Python 3.12, asyncio.get_event_loop() raises RuntimeError when no current event loop is set in the main thread. - Examples updated to explicitly create an event loop with asyncio.new_event_loop() and pass it to IntegrationAPI. - pin pylint version
1 parent f10e1de commit c47e72c

File tree

8 files changed

+20
-12
lines changed

8 files changed

+20
-12
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ permissions:
2020
jobs:
2121
test:
2222
runs-on: ubuntu-24.04
23+
strategy:
24+
matrix:
25+
python-version: ["3.11", "3.12", "3.13"]
2326
steps:
2427
- name: Checkout
2528
uses: actions/checkout@v5
2629

27-
- name: Set up Python
30+
- name: Set up Python ${{ matrix.python-version }}
2831
uses: actions/setup-python@v6
2932
with:
30-
python-version: "3.11"
33+
python-version: ${{ matrix.python-version }}
34+
cache: "pip"
3135

3236
- name: Install pip
3337
run: |

.github/workflows/python-code-format.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ permissions:
2020
jobs:
2121
test:
2222
runs-on: ubuntu-24.04
23+
strategy:
24+
matrix:
25+
python-version: ["3.11", "3.12", "3.13"]
2326

2427
name: Check Python code formatting
2528
steps:
2629
- uses: actions/checkout@v5
2730

28-
- name: Set up Python
31+
- name: Set up Python ${{ matrix.python-version }}
2932
uses: actions/setup-python@v6
3033
with:
31-
python-version: "3.11"
34+
python-version: ${{ matrix.python-version }}
3235

3336
- name: Install dependencies
3437
run: |

examples/hello_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import ucapi
88

9-
loop = asyncio.get_event_loop()
9+
loop = asyncio.new_event_loop()
1010
api = ucapi.IntegrationAPI(loop)
1111

1212

examples/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
create_ui_text,
2121
)
2222

23-
loop = asyncio.get_event_loop()
23+
loop = asyncio.new_event_loop()
2424
api = ucapi.IntegrationAPI(loop)
2525

2626
# Simple commands which are supported by this example remote-entity

examples/setup_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import ucapi
88

9-
loop = asyncio.get_event_loop()
9+
loop = asyncio.new_event_loop()
1010
api = ucapi.IntegrationAPI(loop)
1111

1212

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ classifiers = [
1818
"Topic :: Home Automation",
1919
"Programming Language :: Python :: 3.11",
2020
]
21-
requires-python = ">=3.10"
21+
requires-python = ">=3.11"
2222
dependencies = [
2323
"protobuf~=6.33.2",
2424
"pyee>=9.0",
@@ -40,7 +40,7 @@ content-type = "text/markdown; charset=UTF-8"
4040

4141
[project.optional-dependencies]
4242
testing = [
43-
"pylint",
43+
"pylint==4.0.4",
4444
"flake8-docstrings",
4545
"flake8",
4646
"black",

test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Waiting for: https://github.com/pypa/pip/issues/11440
33
# Workaround: use a pre-commit hook with https://github.com/scikit-image/scikit-image/blob/main/tools/generate_requirements.py
44

5-
pylint
5+
# pin pylint version: it has a tendendy for stricter rules in patch updates!
6+
pylint==4.0.4
67
flake8-docstrings
78
flake8
89
black

ucapi/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ async def init(
151151

152152
if disable_mdns_publish is False:
153153
# Setup zeroconf service info
154-
name = f"{self._driver_info['driver_id']}._uc-integration._tcp.local."
154+
name = f'{self._driver_info["driver_id"]}._uc-integration._tcp.local.'
155155
hostname = local_hostname()
156156
driver_name = _get_default_language_string(
157157
self._driver_info["name"], "Unknown driver"
@@ -1262,7 +1262,7 @@ def local_hostname() -> str:
12621262

12631263
return (
12641264
os.getenv("UC_MDNS_LOCAL_HOSTNAME")
1265-
or f"{socket.gethostname().split('.', 1)[0]}.local."
1265+
or f'{socket.gethostname().split(".", 1)[0]}.local.'
12661266
)
12671267

12681268

0 commit comments

Comments
 (0)