From 5c7c32bbf2a8f7215887400cff11292b0151f0b7 Mon Sep 17 00:00:00 2001 From: Javier de la Puente Date: Fri, 30 Aug 2024 11:53:47 +0200 Subject: [PATCH] fix linting --- rockcraft/extensions/fastapi.py | 14 +++++++------- tests/unit/extensions/test_fastapi.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rockcraft/extensions/fastapi.py b/rockcraft/extensions/fastapi.py index f9ce9bd6c..19495cd8f 100644 --- a/rockcraft/extensions/fastapi.py +++ b/rockcraft/extensions/fastapi.py @@ -66,7 +66,7 @@ def get_root_snippet(self) -> dict[str, Any]: "command" ] = f"/bin/python3 -m uvicorn {self._asgi_path()}" - snippet["parts"] = self._gen_parts() + snippet["parts"] = self._get_parts() return snippet @override @@ -80,11 +80,11 @@ def get_part_snippet(self) -> dict[str, Any]: return {} @property - def name(self): + def name(self) -> str: """Return the normalized name of the rockcraft project.""" return self.yaml_data["name"].replace("-", "_").lower() - def _gen_parts(self) -> dict: + def _get_parts(self) -> dict: """Generate the parts associated with this extension.""" stage_packages = ["python3-venv"] build_environment = [] @@ -101,7 +101,7 @@ def _gen_parts(self) -> dict: "python-requirements": ["requirements.txt"], "build-environment": build_environment, }, - "fastapi-framework/install-app": self._gen_install_app_part(), + "fastapi-framework/install-app": self._get_install_app_part(), } if self.yaml_data["base"] == "bare": parts["fastapi-framework/runtime"] = { @@ -120,7 +120,7 @@ def _gen_parts(self) -> dict: } return parts - def _gen_install_app_part(self): + def _get_install_app_part(self) -> Dict[str, Any]: source_files = [f.name for f in sorted(self.project_root.iterdir())] # if prime is not in exclude mode, use it to generate the stage and organize if self._app_prime and self._app_prime[0] and self._app_prime[0][0] != "-": @@ -145,7 +145,7 @@ def _gen_install_app_part(self): } @property - def _app_prime(self): + def _app_prime(self) -> list[str]: """Return the prime list for the FastAPI project.""" user_prime = ( self.yaml_data.get("parts", {}) @@ -213,7 +213,7 @@ def _find_asgi_location(self) -> pathlib.Path: raise FileNotFoundError("ASGI entrypoint not found") - def _check_project(self): + def _check_project(self) -> None: """Ensure this extension can apply to the current rockcraft project.""" error_messages = self._requirements_txt_error_messages() if not self.yaml_data.get("services", {}).get("fastapi", {}).get("command"): diff --git a/tests/unit/extensions/test_fastapi.py b/tests/unit/extensions/test_fastapi.py index 77a1ea43a..9d2cff2f4 100644 --- a/tests/unit/extensions/test_fastapi.py +++ b/tests/unit/extensions/test_fastapi.py @@ -261,7 +261,7 @@ def test_fastapi_framework_exclude_prime(tmp_path, fastapi_input_yaml): @pytest.mark.usefixtures("fastapi_extension") -def test_fastapi_framework_service_override(tmp_path, fastapi_input_yaml): +def test_fastapi_framework_service_overridden(tmp_path, fastapi_input_yaml): (tmp_path / "requirements.txt").write_text("fastapi") (tmp_path / "webapp.py").write_text("app = object()") fastapi_input_yaml["services"] = {