Skip to content

Commit

Permalink
changes for 2025.1.1, bumped python to 3.13.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigbarratt committed Jan 8, 2025
1 parent 60956f0 commit a88a0e6
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
with:
python-version: "3.12"
python-version: "3.13"
- run: python3 -m pip install black
- run: black .

Expand All @@ -29,7 +29,7 @@ jobs:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
with:
python-version: "3.12"
python-version: "3.13"
- run: python3 -m pip install -r tests/requirements_test.txt
- run: pytest --cov=custom_components

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

Expand All @@ -51,6 +51,6 @@ jobs:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
with:
python-version: "3.12"
python-version: "3.13"
- run: python3 -m pip install -r tests/requirements_test.txt
- run: mypy custom_components/pyscript/*.py tests/*.py
4 changes: 2 additions & 2 deletions custom_components/pyscript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
SERVICE_RELOAD,
)
from homeassistant.core import Event as HAEvent, HomeAssistant, ServiceCall
from homeassistant.helpers.typing import ConfigType
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.restore_state import DATA_RESTORE_STATE
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass

from .const import (
Expand Down Expand Up @@ -151,7 +151,7 @@ class WatchDogHandler(FileSystemEventHandler):
"""Class for handling watchdog events."""

def __init__(
self, watchdog_q: asyncio.Queue, observer: watchdog.observers.Observer, path: str
self, watchdog_q: asyncio.Queue, observer: watchdog.observers.ObserverType, path: str
) -> None:
self.watchdog_q = watchdog_q
self._observer = observer
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pyscript/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"homekit": {},
"iot_class": "local_push",
"issue_tracker": "https://github.com/custom-components/pyscript/issues",
"requirements": ["croniter==2.0.2", "watchdog==2.3.1"],
"requirements": ["croniter==6.0.0", "watchdog==6.0.0"],
"ssdp": [],
"version": "1.6.1",
"zeroconf": []
Expand Down
21 changes: 21 additions & 0 deletions docs/new_features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ to see the development version of the documentation.
If you want to see development progress since 1.6.1, see
`new features <https://hacs-pyscript.readthedocs.io/en/latest/new_features.html>`__ in the latest
documentation, or look at the `GitHub repository <https://github.com/custom-components/pyscript>`__.

Planned new features post 1.6.1 include:

- Services defined in pyscript should support entity methods if they include an ``entity_id`` keyword argument.
- Consider supporting the built-in functions that do I/O, such as ``open``, ``read`` and ``write``, which
are not currently supported to avoid I/O in the main event loop, and also to avoid security issues if people
share pyscripts. The ``print`` function only logs a message, rather than implements the real ``print`` features,
such as specifying an output file handle. Support might be added in the future using an executor job, perhaps
enabled when ``allow_all_imports`` is set.

The new features since 1.6.1 in master include:

None yet.

Breaking changes since 1.6.1 include:

None yet.

Bug fixes since 1.6.1 include:

None yet.
1 change: 1 addition & 0 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ disable=
too-many-instance-attributes,
too-many-lines,
too-many-locals,
too-many-positional-arguments,
too-many-public-methods,
too-many-return-statements,
too-many-statements,
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[tool.black]
line-length = 109

#[tool.pytest.ini_options]
#asyncio_mode = "auto"
#asyncio_default_fixture_loop_scope = "function"
16 changes: 8 additions & 8 deletions tests/requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
coverage==7.5.3
croniter==2.0.2
watchdog==2.3.1
coverage==7.6.8
croniter==6.0.0
watchdog==6.0.0
mock-open==1.4.0
mypy==1.10.1
pre-commit==3.7.1
pytest==8.2.0
pytest-cov==5.0.0
pytest-homeassistant-custom-component==0.13.145
pylint==3.2.5
pylint-strict-informational==0.1
pytest==8.3.4
pytest-cov==6.0.0
pytest-homeassistant-custom-component==0.13.201
pylint==3.3.2
pylint-strict-informational==0.1
60 changes: 30 additions & 30 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ async def test_user_flow_minimum_fields(hass, pyscript_bypass_setup):
"""Test user config flow with minimum fields."""
# test form shows
result = await hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_USER})
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"

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

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

assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"

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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert CONF_ALLOW_ALL_IMPORTS in result["data"]
assert result["data"][CONF_ALLOW_ALL_IMPORTS]
assert result["data"][CONF_HASS_IS_GLOBAL]
Expand All @@ -66,15 +66,15 @@ async def test_user_already_configured(hass, pyscript_bypass_setup):
data={CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True},
)

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY

result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={CONF_ALLOW_ALL_IMPORTS: True, CONF_HASS_IS_GLOBAL: True},
)

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed"


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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY


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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY

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

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "updated_entry"


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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY

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

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "updated_entry"


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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY

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

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "updated_entry"


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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY

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

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "already_configured"


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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY

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

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "updated_entry"

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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY

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

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["reason"] == "updated_entry"

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

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

assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "no_ui_configuration_allowed"

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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["title"] == ""


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

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

assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "init"

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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["title"] == ""

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

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

assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "init"

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

assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "no_update"

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

assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["title"] == ""


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

0 comments on commit a88a0e6

Please sign in to comment.