From 2da426be16d14fe4fda6db5a9f2c0cd7440bb503 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:29:53 +0000 Subject: [PATCH 1/6] Bump the required group across 1 directory with 19 updates Bumps the required group with 19 updates in the / directory: | Package | From | To | | --- | --- | --- | | [prompt-toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit) | `3.0.47` | `3.0.48` | | [flake8](https://github.com/pycqa/flake8) | `7.1.0` | `7.1.1` | | [pydoclint](https://github.com/jsh9/pydoclint) | `0.5.3` | `0.5.9` | | [black](https://github.com/psf/black) | `24.4.2` | `24.8.0` | | [markdown](https://github.com/Python-Markdown/markdown) | `3.6` | `3.7` | | [mike](https://github.com/jimporter/mike) | `2.1.2` | `2.1.3` | | [mkdocs-macros-plugin](https://github.com/fralau/mkdocs_macros_plugin) | `1.0.5` | `1.2.0` | | [mkdocs-material](https://github.com/squidfunk/mkdocs-material) | `9.5.27` | `9.5.39` | | [mkdocstrings[python]](https://github.com/mkdocstrings/mkdocstrings) | `0.25.1` | `0.26.1` | | [frequenz-repo-config[lib]](https://github.com/frequenz-floss/frequenz-repo-config-python) | `0.9.2` | `0.10.0` | | [mypy](https://github.com/python/mypy) | `1.10.1` | `1.11.2` | | [types-markdown](https://github.com/python/typeshed) | `3.6.0.20240316` | `3.7.0.20240822` | | [types-protobuf](https://github.com/python/typeshed) | `5.27.0.20240626` | `5.28.0.20240924` | | [pylint](https://github.com/pylint-dev/pylint) | `3.2.5` | `3.3.1` | | [pytest](https://github.com/pytest-dev/pytest) | `8.2.2` | `8.3.3` | | [frequenz-repo-config[extra-lint-examples]](https://github.com/frequenz-floss/frequenz-repo-config-python) | `0.9.2` | `0.10.0` | | [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) | `0.23.7` | `0.24.0` | | [async-solipsism](https://github.com/bmerry/async-solipsism) | `0.6` | `0.7` | | [hypothesis](https://github.com/HypothesisWorks/hypothesis) | `6.104.2` | `6.112.2` | Updates `prompt-toolkit` from 3.0.47 to 3.0.48 - [Release notes](https://github.com/prompt-toolkit/python-prompt-toolkit/releases) - [Changelog](https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/CHANGELOG) - [Commits](https://github.com/prompt-toolkit/python-prompt-toolkit/compare/3.0.47...3.0.48) Updates `flake8` from 7.1.0 to 7.1.1 - [Commits](https://github.com/pycqa/flake8/compare/7.1.0...7.1.1) Updates `pydoclint` from 0.5.3 to 0.5.9 - [Release notes](https://github.com/jsh9/pydoclint/releases) - [Changelog](https://github.com/jsh9/pydoclint/blob/main/CHANGELOG.md) - [Commits](https://github.com/jsh9/pydoclint/compare/0.5.3...0.5.9) Updates `black` from 24.4.2 to 24.8.0 - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/24.4.2...24.8.0) Updates `markdown` from 3.6 to 3.7 - [Release notes](https://github.com/Python-Markdown/markdown/releases) - [Changelog](https://github.com/Python-Markdown/markdown/blob/master/docs/changelog.md) - [Commits](https://github.com/Python-Markdown/markdown/compare/3.6...3.7) Updates `mike` from 2.1.2 to 2.1.3 - [Release notes](https://github.com/jimporter/mike/releases) - [Changelog](https://github.com/jimporter/mike/blob/master/CHANGES.md) - [Commits](https://github.com/jimporter/mike/compare/v2.1.2...v2.1.3) Updates `mkdocs-macros-plugin` from 1.0.5 to 1.2.0 - [Release notes](https://github.com/fralau/mkdocs_macros_plugin/releases) - [Changelog](https://github.com/fralau/mkdocs-macros-plugin/blob/master/CHANGELOG.md) - [Commits](https://github.com/fralau/mkdocs_macros_plugin/compare/v1.0.5...v1.2.0) Updates `mkdocs-material` from 9.5.27 to 9.5.39 - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.5.27...9.5.39) Updates `mkdocstrings[python]` from 0.25.1 to 0.26.1 - [Release notes](https://github.com/mkdocstrings/mkdocstrings/releases) - [Changelog](https://github.com/mkdocstrings/mkdocstrings/blob/main/CHANGELOG.md) - [Commits](https://github.com/mkdocstrings/mkdocstrings/compare/0.25.1...0.26.1) Updates `frequenz-repo-config[lib]` from 0.9.2 to 0.10.0 - [Release notes](https://github.com/frequenz-floss/frequenz-repo-config-python/releases) - [Changelog](https://github.com/frequenz-floss/frequenz-repo-config-python/blob/v0.10.0/RELEASE_NOTES.md) - [Commits](https://github.com/frequenz-floss/frequenz-repo-config-python/compare/v0.9.2...v0.10.0) Updates `mypy` from 1.10.1 to 1.11.2 - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.10.1...v1.11.2) Updates `types-markdown` from 3.6.0.20240316 to 3.7.0.20240822 - [Commits](https://github.com/python/typeshed/commits) Updates `types-protobuf` from 5.27.0.20240626 to 5.28.0.20240924 - [Commits](https://github.com/python/typeshed/commits) Updates `pylint` from 3.2.5 to 3.3.1 - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.2.5...v3.3.1) Updates `pytest` from 8.2.2 to 8.3.3 - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.2.2...8.3.3) Updates `frequenz-repo-config[extra-lint-examples]` from 0.9.2 to 0.10.0 - [Release notes](https://github.com/frequenz-floss/frequenz-repo-config-python/releases) - [Changelog](https://github.com/frequenz-floss/frequenz-repo-config-python/blob/v0.10.0/RELEASE_NOTES.md) - [Commits](https://github.com/frequenz-floss/frequenz-repo-config-python/compare/v0.9.2...v0.10.0) Updates `pytest-asyncio` from 0.23.7 to 0.24.0 - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.23.7...v0.24.0) Updates `async-solipsism` from 0.6 to 0.7 - [Commits](https://github.com/bmerry/async-solipsism/commits) Updates `hypothesis` from 6.104.2 to 6.112.2 - [Release notes](https://github.com/HypothesisWorks/hypothesis/releases) - [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.104.2...hypothesis-python-6.112.2) --- updated-dependencies: - dependency-name: prompt-toolkit dependency-type: direct:production update-type: version-update:semver-patch dependency-group: required - dependency-name: flake8 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: required - dependency-name: pydoclint dependency-type: direct:production update-type: version-update:semver-patch dependency-group: required - dependency-name: black dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: markdown dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: mike dependency-type: direct:production update-type: version-update:semver-patch dependency-group: required - dependency-name: mkdocs-macros-plugin dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch dependency-group: required - dependency-name: mkdocstrings[python] dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: frequenz-repo-config[lib] dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: types-markdown dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: types-protobuf dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: frequenz-repo-config[extra-lint-examples] dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: async-solipsism dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required - dependency-name: hypothesis dependency-type: direct:production update-type: version-update:semver-minor dependency-group: required ... Signed-off-by: dependabot[bot] --- pyproject.toml | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d0b60da9..647f3d51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires = [ "setuptools == 68.1.0", "setuptools_scm[toml] == 7.1.0", - "frequenz-repo-config[lib] == 0.9.2", + "frequenz-repo-config[lib] == 0.10.0", ] build-backend = "setuptools.build_meta" @@ -52,49 +52,49 @@ name = "Frequenz Energy-as-a-Service GmbH" email = "floss@frequenz.com" [project.optional-dependencies] -cli = ["asyncclick == 8.1.7.2", "prompt-toolkit == 3.0.47", "parsedatetime==2.6", "tzlocal==5.2"] +cli = ["asyncclick == 8.1.7.2", "prompt-toolkit == 3.0.48", "parsedatetime==2.6", "tzlocal==5.2"] dev-flake8 = [ - "flake8 == 7.1.0", + "flake8 == 7.1.1", "flake8-docstrings == 1.7.0", "flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml - "pydoclint == 0.5.3", + "pydoclint == 0.5.9", "pydocstyle == 6.3.0", ] -dev-formatting = ["black == 24.4.2", "isort == 5.13.2"] +dev-formatting = ["black == 24.8.0", "isort == 5.13.2"] dev-mkdocs = [ - "black == 24.4.2", - "Markdown==3.6", - "mike == 2.1.2", + "black == 24.8.0", + "Markdown==3.7", + "mike == 2.1.3", "mkdocs-gen-files == 0.5.0", "mkdocs-literate-nav == 0.6.1", - "mkdocs-macros-plugin == 1.0.5", - "mkdocs-material == 9.5.27", - "mkdocstrings[python] == 0.25.1", - "frequenz-repo-config[lib] == 0.9.2", + "mkdocs-macros-plugin == 1.2.0", + "mkdocs-material == 9.5.39", + "mkdocstrings[python] == 0.26.1", + "frequenz-repo-config[lib] == 0.10.0", ] dev-mypy = [ - "mypy == 1.10.1", - "types-Markdown == 3.6.0.20240316", + "mypy == 1.11.2", + "types-Markdown == 3.7.0.20240822", # For checking the noxfile, docs/ script, and tests "frequenz-client-dispatch[cli,dev-mkdocs,dev-noxfile,dev-pytest]", "grpc-stubs == 1.53.0.5", - "types-protobuf == 5.27.0.20240626", + "types-protobuf == 5.28.0.20240924", ] -dev-noxfile = ["nox == 2024.4.15", "frequenz-repo-config[lib] == 0.9.2"] +dev-noxfile = ["nox == 2024.4.15", "frequenz-repo-config[lib] == 0.10.0"] dev-pylint = [ - "pylint == 3.2.5", + "pylint == 3.3.1", # For checking the noxfile, docs/ script, and tests "frequenz-client-dispatch[cli,dev-mkdocs,dev-noxfile,dev-pytest]", "frequenz-api-dispatch >= 0.15.1, < 0.16", ] dev-pytest = [ - "pytest == 8.2.2", - "frequenz-repo-config[extra-lint-examples] == 0.9.2", + "pytest == 8.3.3", + "frequenz-repo-config[extra-lint-examples] == 0.10.0", "pytest-mock == 3.14.0", - "pytest-asyncio == 0.23.7", - "async-solipsism == 0.6", - "hypothesis == 6.104.2", + "pytest-asyncio == 0.24.0", + "async-solipsism == 0.7", + "hypothesis == 6.112.2", "frequenz-client-dispatch[cli]", ] dev = [ From 5b7296e1b6b8953eb992e21235c26207dab61f3d Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 3 Oct 2024 12:35:21 +0200 Subject: [PATCH 2/6] Make optional arguments keyword-only Both `Client.create()` and `Client.list() now take all optional arguments as keyword-only arguments. This is to improve readability and make calls less error prone, as these argument also have sometimes the same time, making it hard to figure out which is which (for example, `start_from` and `start_to` in `list()` or `active` and `dry_run` in `create`). Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 1 + src/frequenz/client/dispatch/_client.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 98e9160d..1302ad94 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,7 @@ ## Upgrading * `Client.stream()` will now raise an Exception when the connection is lost. +* `Client.create()` and `Client.list() now take all optional arguments as keyword-only arguments. ## New Features diff --git a/src/frequenz/client/dispatch/_client.py b/src/frequenz/client/dispatch/_client.py index 8f24b788..3052ccba 100644 --- a/src/frequenz/client/dispatch/_client.py +++ b/src/frequenz/client/dispatch/_client.py @@ -93,6 +93,7 @@ def __init__( async def list( self, microgrid_id: int, + *, component_selectors: Iterator[ComponentSelector] = iter(()), start_from: datetime | None = None, start_to: datetime | None = None, @@ -231,13 +232,14 @@ def _get_stream( return broadcaster - async def create( + async def create( # pylint: disable=too-many-positional-arguments self, microgrid_id: int, type: str, # pylint: disable=redefined-builtin start_time: datetime, duration: timedelta | None, selector: ComponentSelector, + *, active: bool = True, dry_run: bool = False, payload: dict[str, Any] | None = None, From d8e1338e7bdd57cd4be8ba0409598555a3bea667 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 3 Oct 2024 12:36:35 +0200 Subject: [PATCH 3/6] Remove wrong exception documentation The `create` RPC now returns the `Dispatch` object, so the call cannot fail because the dispatch was not found anymore. Signed-off-by: Leandro Lucarella --- src/frequenz/client/dispatch/_client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/frequenz/client/dispatch/_client.py b/src/frequenz/client/dispatch/_client.py index 3052ccba..8af510d7 100644 --- a/src/frequenz/client/dispatch/_client.py +++ b/src/frequenz/client/dispatch/_client.py @@ -267,7 +267,6 @@ async def create( # pylint: disable=too-many-positional-arguments Raises: ValueError: If start_time is in the past. - ValueError: If the created dispatch could not be found. """ if start_time <= datetime.now(tz=start_time.tzinfo): raise ValueError("start_time must not be in the past") From 1b4812dd81a53b845ebaa6b023b5773898f9ae2a Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 3 Oct 2024 12:37:07 +0200 Subject: [PATCH 4/6] Remove unnecessary `type: ignore` It seems like the new version of `mypy` can now figure out types better now. Signed-off-by: Leandro Lucarella --- tests/test_dispatch_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_dispatch_types.py b/tests/test_dispatch_types.py index a5d4dcd3..1da99f0e 100644 --- a/tests/test_dispatch_types.py +++ b/tests/test_dispatch_types.py @@ -28,7 +28,7 @@ def test_component_selector() -> None: [ComponentCategory.METER], [ComponentCategory.EV_CHARGER, ComponentCategory.BATTERY], ): - protobuf = component_selector_to_protobuf(selector) # type: ignore + protobuf = component_selector_to_protobuf(selector) assert component_selector_from_protobuf(protobuf) == selector From 8915349715df606e26a00b087054b9af8aca5b79 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 3 Oct 2024 12:41:54 +0200 Subject: [PATCH 5/6] Disable some `pylint` checks for all test functions Move the `pylint: disable=xxx` directive to the point in the file where we start to write the test functions, as we always want to ignore those checks for these type of functions. Signed-off-by: Leandro Lucarella --- tests/test_dispatch_cli.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_dispatch_cli.py b/tests/test_dispatch_cli.py index 25f2c93b..0fc1700e 100644 --- a/tests/test_dispatch_cli.py +++ b/tests/test_dispatch_cli.py @@ -48,6 +48,12 @@ def mock_client(fake_client: FakeClient) -> Generator[None, None, None]: yield +# For test functions we want to disable some pylint checks, we need many +# arguments to pass fixtures, these functions are not meant to be called directly, and +# having too many locals in tests is not a problem either. +# pylint: disable=too-many-arguments,too-many-locals + + @pytest.mark.asyncio @pytest.mark.parametrize( "dispatches, microgrid_id, expected_output, expected_return_code", @@ -142,7 +148,7 @@ def mock_client(fake_client: FakeClient) -> Generator[None, None, None]: ), ], ) -async def test_list_command( # pylint: disable=too-many-arguments +async def test_list_command( runner: CliRunner, fake_client: FakeClient, dispatches: dict[int, list[Dispatch]], @@ -305,7 +311,7 @@ async def test_list_command( # pylint: disable=too-many-arguments ), ], ) -async def test_create_command( # pylint: disable=too-many-arguments,too-many-locals +async def test_create_command( runner: CliRunner, fake_client: FakeClient, args: list[str], @@ -529,7 +535,7 @@ async def test_create_command( # pylint: disable=too-many-arguments,too-many-lo ), ], ) -async def test_update_command( # pylint: disable=too-many-arguments +async def test_update_command( runner: CliRunner, fake_client: FakeClient, dispatches: list[Dispatch], @@ -631,7 +637,7 @@ async def test_get_command( ), ], ) -async def test_delete_command( # pylint: disable=too-many-arguments +async def test_delete_command( runner: CliRunner, fake_client: FakeClient, dispatches: list[Dispatch], From 42a697029a0d0c3973260eb149b4403b9683c63f Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 3 Oct 2024 12:42:03 +0200 Subject: [PATCH 6/6] Disable `too-many-positional-arguments` pylint check in tests This is a new check performed by the new `pylint` version, and we want to disable it too for all test functions. Signed-off-by: Leandro Lucarella --- tests/test_dispatch_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_dispatch_cli.py b/tests/test_dispatch_cli.py index 0fc1700e..92e67b32 100644 --- a/tests/test_dispatch_cli.py +++ b/tests/test_dispatch_cli.py @@ -48,10 +48,10 @@ def mock_client(fake_client: FakeClient) -> Generator[None, None, None]: yield -# For test functions we want to disable some pylint checks, we need many +# For test functions we want to disable some pylint checks, we need many (positional) # arguments to pass fixtures, these functions are not meant to be called directly, and # having too many locals in tests is not a problem either. -# pylint: disable=too-many-arguments,too-many-locals +# pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-locals @pytest.mark.asyncio