Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
javierdelapuente committed Aug 30, 2024
1 parent 290f641 commit 5c7c32b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions rockcraft/extensions/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = []
Expand All @@ -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"] = {
Expand All @@ -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] != "-":
Expand All @@ -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", {})
Expand Down Expand Up @@ -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"):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/extensions/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] = {
Expand Down

0 comments on commit 5c7c32b

Please sign in to comment.