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/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 = [ diff --git a/src/frequenz/client/dispatch/_client.py b/src/frequenz/client/dispatch/_client.py index 8f24b788..8af510d7 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, @@ -265,7 +267,6 @@ async def create( 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") diff --git a/tests/test_dispatch_cli.py b/tests/test_dispatch_cli.py index 25f2c93b..92e67b32 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 (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-positional-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], 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