Skip to content

Commit a88a0e6

Browse files
committed
changes for 2025.1.1, bumped python to 3.13.0.
1 parent 60956f0 commit a88a0e6

File tree

8 files changed

+71
-45
lines changed

8 files changed

+71
-45
lines changed

.github/workflows/validate.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: "actions/checkout@v2"
1919
- uses: "actions/setup-python@v1"
2020
with:
21-
python-version: "3.12"
21+
python-version: "3.13"
2222
- run: python3 -m pip install black
2323
- run: black .
2424

@@ -29,7 +29,7 @@ jobs:
2929
- uses: "actions/checkout@v2"
3030
- uses: "actions/setup-python@v1"
3131
with:
32-
python-version: "3.12"
32+
python-version: "3.13"
3333
- run: python3 -m pip install -r tests/requirements_test.txt
3434
- run: pytest --cov=custom_components
3535

@@ -40,7 +40,7 @@ jobs:
4040
- uses: "actions/checkout@v2"
4141
- uses: "actions/setup-python@v1"
4242
with:
43-
python-version: "3.12"
43+
python-version: "3.13"
4444
- run: python3 -m pip install -r tests/requirements_test.txt
4545
- run: pylint custom_components/pyscript/*.py tests/*.py
4646

@@ -51,6 +51,6 @@ jobs:
5151
- uses: "actions/checkout@v2"
5252
- uses: "actions/setup-python@v1"
5353
with:
54-
python-version: "3.12"
54+
python-version: "3.13"
5555
- run: python3 -m pip install -r tests/requirements_test.txt
5656
- run: mypy custom_components/pyscript/*.py tests/*.py

custom_components/pyscript/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
SERVICE_RELOAD,
2323
)
2424
from homeassistant.core import Event as HAEvent, HomeAssistant, ServiceCall
25-
from homeassistant.helpers.typing import ConfigType
2625
from homeassistant.exceptions import HomeAssistantError
2726
import homeassistant.helpers.config_validation as cv
2827
from homeassistant.helpers.restore_state import DATA_RESTORE_STATE
28+
from homeassistant.helpers.typing import ConfigType
2929
from homeassistant.loader import bind_hass
3030

3131
from .const import (
@@ -151,7 +151,7 @@ class WatchDogHandler(FileSystemEventHandler):
151151
"""Class for handling watchdog events."""
152152

153153
def __init__(
154-
self, watchdog_q: asyncio.Queue, observer: watchdog.observers.Observer, path: str
154+
self, watchdog_q: asyncio.Queue, observer: watchdog.observers.ObserverType, path: str
155155
) -> None:
156156
self.watchdog_q = watchdog_q
157157
self._observer = observer

custom_components/pyscript/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"homekit": {},
1111
"iot_class": "local_push",
1212
"issue_tracker": "https://github.com/custom-components/pyscript/issues",
13-
"requirements": ["croniter==2.0.2", "watchdog==2.3.1"],
13+
"requirements": ["croniter==6.0.0", "watchdog==6.0.0"],
1414
"ssdp": [],
1515
"version": "1.6.1",
1616
"zeroconf": []

docs/new_features.rst

+21
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ to see the development version of the documentation.
2020
If you want to see development progress since 1.6.1, see
2121
`new features <https://hacs-pyscript.readthedocs.io/en/latest/new_features.html>`__ in the latest
2222
documentation, or look at the `GitHub repository <https://github.com/custom-components/pyscript>`__.
23+
24+
Planned new features post 1.6.1 include:
25+
26+
- Services defined in pyscript should support entity methods if they include an ``entity_id`` keyword argument.
27+
- Consider supporting the built-in functions that do I/O, such as ``open``, ``read`` and ``write``, which
28+
are not currently supported to avoid I/O in the main event loop, and also to avoid security issues if people
29+
share pyscripts. The ``print`` function only logs a message, rather than implements the real ``print`` features,
30+
such as specifying an output file handle. Support might be added in the future using an executor job, perhaps
31+
enabled when ``allow_all_imports`` is set.
32+
33+
The new features since 1.6.1 in master include:
34+
35+
None yet.
36+
37+
Breaking changes since 1.6.1 include:
38+
39+
None yet.
40+
41+
Bug fixes since 1.6.1 include:
42+
43+
None yet.

pylintrc

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ disable=
4242
too-many-instance-attributes,
4343
too-many-lines,
4444
too-many-locals,
45+
too-many-positional-arguments,
4546
too-many-public-methods,
4647
too-many-return-statements,
4748
too-many-statements,

pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
[tool.black]
22
line-length = 109
3+
4+
#[tool.pytest.ini_options]
5+
#asyncio_mode = "auto"
6+
#asyncio_default_fixture_loop_scope = "function"

tests/requirements_test.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
coverage==7.5.3
2-
croniter==2.0.2
3-
watchdog==2.3.1
1+
coverage==7.6.8
2+
croniter==6.0.0
3+
watchdog==6.0.0
44
mock-open==1.4.0
55
mypy==1.10.1
66
pre-commit==3.7.1
7-
pytest==8.2.0
8-
pytest-cov==5.0.0
9-
pytest-homeassistant-custom-component==0.13.145
10-
pylint==3.2.5
11-
pylint-strict-informational==0.1
7+
pytest==8.3.4
8+
pytest-cov==6.0.0
9+
pytest-homeassistant-custom-component==0.13.201
10+
pylint==3.3.2
11+
pylint-strict-informational==0.1

tests/test_config_flow.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ async def test_user_flow_minimum_fields(hass, pyscript_bypass_setup):
2626
"""Test user config flow with minimum fields."""
2727
# test form shows
2828
result = await hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_USER})
29-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
29+
assert result["type"] == data_entry_flow.FlowResultType.FORM
3030
assert result["step_id"] == "user"
3131

3232
result = await hass.config_entries.flow.async_configure(result["flow_id"], user_input={})
3333

34-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
34+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
3535
assert CONF_ALLOW_ALL_IMPORTS in result["data"]
3636
assert CONF_HASS_IS_GLOBAL in result["data"]
3737
assert not result["data"][CONF_ALLOW_ALL_IMPORTS]
@@ -44,14 +44,14 @@ async def test_user_flow_all_fields(hass, pyscript_bypass_setup):
4444
# test form shows
4545
result = await hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_USER})
4646

47-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
47+
assert result["type"] == data_entry_flow.FlowResultType.FORM
4848
assert result["step_id"] == "user"
4949

5050
result = await hass.config_entries.flow.async_configure(
5151
result["flow_id"], user_input={CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}
5252
)
5353

54-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
54+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
5555
assert CONF_ALLOW_ALL_IMPORTS in result["data"]
5656
assert result["data"][CONF_ALLOW_ALL_IMPORTS]
5757
assert result["data"][CONF_HASS_IS_GLOBAL]
@@ -66,15 +66,15 @@ async def test_user_already_configured(hass, pyscript_bypass_setup):
6666
data={CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True},
6767
)
6868

69-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
69+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
7070

7171
result = await hass.config_entries.flow.async_init(
7272
DOMAIN,
7373
context={"source": SOURCE_USER},
7474
data={CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True},
7575
)
7676

77-
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
77+
assert result["type"] == data_entry_flow.FlowResultType.ABORT
7878
assert result["reason"] == "single_instance_allowed"
7979

8080

@@ -85,7 +85,7 @@ async def test_import_flow(hass, pyscript_bypass_setup):
8585
DOMAIN, context={"source": SOURCE_IMPORT}, data=PYSCRIPT_SCHEMA({})
8686
)
8787

88-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
88+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
8989

9090

9191
@pytest.mark.asyncio
@@ -95,15 +95,15 @@ async def test_import_flow_update_allow_all_imports(hass, pyscript_bypass_setup)
9595
DOMAIN, context={"source": SOURCE_IMPORT}, data=PYSCRIPT_SCHEMA({})
9696
)
9797

98-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
98+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
9999

100100
result = await hass.config_entries.flow.async_init(
101101
DOMAIN,
102102
context={"source": SOURCE_IMPORT},
103103
data={CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True},
104104
)
105105

106-
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
106+
assert result["type"] == data_entry_flow.FlowResultType.ABORT
107107
assert result["reason"] == "updated_entry"
108108

109109

@@ -114,13 +114,13 @@ async def test_import_flow_update_apps_from_none(hass, pyscript_bypass_setup):
114114
DOMAIN, context={"source": SOURCE_IMPORT}, data=PYSCRIPT_SCHEMA({})
115115
)
116116

117-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
117+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
118118

119119
result = await hass.config_entries.flow.async_init(
120120
DOMAIN, context={"source": SOURCE_IMPORT}, data={"apps": {"test_app": {"param": 1}}}
121121
)
122122

123-
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
123+
assert result["type"] == data_entry_flow.FlowResultType.ABORT
124124
assert result["reason"] == "updated_entry"
125125

126126

@@ -131,11 +131,11 @@ async def test_import_flow_update_apps_to_none(hass, pyscript_bypass_setup):
131131
DOMAIN, context={"source": SOURCE_IMPORT}, data=PYSCRIPT_SCHEMA({"apps": {"test_app": {"param": 1}}})
132132
)
133133

134-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
134+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
135135

136136
result = await hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_IMPORT}, data={})
137137

138-
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
138+
assert result["type"] == data_entry_flow.FlowResultType.ABORT
139139
assert result["reason"] == "updated_entry"
140140

141141

@@ -146,13 +146,13 @@ async def test_import_flow_no_update(hass, pyscript_bypass_setup):
146146
DOMAIN, context={"source": SOURCE_IMPORT}, data=PYSCRIPT_SCHEMA({})
147147
)
148148

149-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
149+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
150150

151151
result = await hass.config_entries.flow.async_init(
152152
DOMAIN, context={"source": SOURCE_IMPORT}, data=PYSCRIPT_SCHEMA({})
153153
)
154154

155-
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
155+
assert result["type"] == data_entry_flow.FlowResultType.ABORT
156156
assert result["reason"] == "already_configured"
157157

158158

@@ -165,13 +165,13 @@ async def test_import_flow_update_user(hass, pyscript_bypass_setup):
165165
data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}),
166166
)
167167

168-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
168+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
169169

170170
result = await hass.config_entries.flow.async_init(
171171
DOMAIN, context={"source": SOURCE_IMPORT}, data={"apps": {"test_app": {"param": 1}}}
172172
)
173173

174-
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
174+
assert result["type"] == data_entry_flow.FlowResultType.ABORT
175175
assert result["reason"] == "updated_entry"
176176

177177
assert hass.config_entries.async_entries(DOMAIN)[0].data == {
@@ -190,13 +190,13 @@ async def test_import_flow_update_import(hass, pyscript_bypass_setup):
190190
data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}),
191191
)
192192

193-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
193+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
194194

195195
result = await hass.config_entries.flow.async_init(
196196
DOMAIN, context={"source": SOURCE_IMPORT}, data={"apps": {"test_app": {"param": 1}}}
197197
)
198198

199-
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
199+
assert result["type"] == data_entry_flow.FlowResultType.ABORT
200200
assert result["reason"] == "updated_entry"
201201

202202
assert hass.config_entries.async_entries(DOMAIN)[0].data == {"apps": {"test_app": {"param": 1}}}
@@ -211,17 +211,17 @@ async def test_options_flow_import(hass, pyscript_bypass_setup):
211211
data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}),
212212
)
213213
await hass.async_block_till_done()
214-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
214+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
215215
entry = result["result"]
216216

217217
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
218218

219-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
219+
assert result["type"] == data_entry_flow.FlowResultType.FORM
220220
assert result["step_id"] == "no_ui_configuration_allowed"
221221

222222
result = await hass.config_entries.options.async_configure(result["flow_id"], user_input=None)
223223

224-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
224+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
225225
assert result["title"] == ""
226226

227227

@@ -234,20 +234,20 @@ async def test_options_flow_user_change(hass, pyscript_bypass_setup):
234234
data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}),
235235
)
236236
await hass.async_block_till_done()
237-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
237+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
238238
entry = result["result"]
239239

240240
result = await hass.config_entries.options.async_init(entry.entry_id)
241241

242-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
242+
assert result["type"] == data_entry_flow.FlowResultType.FORM
243243
assert result["step_id"] == "init"
244244

245245
result = await hass.config_entries.options.async_configure(
246246
result["flow_id"], user_input={CONF_ALLOW_ALL_IMPORTS: False, CONF_HASS_IS_GLOBAL: False}
247247
)
248248
await hass.async_block_till_done()
249249

250-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
250+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
251251
assert result["title"] == ""
252252

253253
assert entry.data[CONF_ALLOW_ALL_IMPORTS] is False
@@ -263,24 +263,24 @@ async def test_options_flow_user_no_change(hass, pyscript_bypass_setup):
263263
data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}),
264264
)
265265
await hass.async_block_till_done()
266-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
266+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
267267
entry = result["result"]
268268

269269
result = await hass.config_entries.options.async_init(entry.entry_id)
270270

271-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
271+
assert result["type"] == data_entry_flow.FlowResultType.FORM
272272
assert result["step_id"] == "init"
273273

274274
result = await hass.config_entries.options.async_configure(
275275
result["flow_id"], user_input={CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}
276276
)
277277

278-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
278+
assert result["type"] == data_entry_flow.FlowResultType.FORM
279279
assert result["step_id"] == "no_update"
280280

281281
result = await hass.config_entries.options.async_configure(result["flow_id"], user_input=None)
282282

283-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
283+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
284284
assert result["title"] == ""
285285

286286

@@ -296,7 +296,7 @@ async def test_config_entry_reload(hass):
296296
data=PYSCRIPT_SCHEMA({CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True}),
297297
)
298298
await hass.async_block_till_done()
299-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
299+
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
300300
entry = result["result"]
301301
listeners = hass.bus.async_listeners()
302302
await hass.config_entries.async_reload(entry.entry_id)

0 commit comments

Comments
 (0)