Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with Starbase #422

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6fe4c5b
chore(linter): use starbase
syu-w Nov 28, 2023
42670ba
chore(deps): sync dev deps with starbase
syu-w Nov 28, 2023
ab04163
chore(tests): update tox.ini with starbase
syu-w Nov 28, 2023
c20d6d5
chore(linter): update to 3.10 style
syu-w Nov 28, 2023
518aa7e
chore(linter): misc auto fix
syu-w Nov 28, 2023
bbb3493
chore(linter): use tuple for pytest.mark.parametrize
syu-w Nov 28, 2023
9fc89bc
chore(linter): create list without concatenate
syu-w Nov 28, 2023
d9ef893
chore(linter): misc fix
syu-w Nov 28, 2023
d1a6efb
chore(linter): fix some annotations
syu-w Nov 28, 2023
d4b888a
chore(linter): temporarily turn off unfixed rules
syu-w Nov 29, 2023
39303dc
feat(project): migrate to pyproject.toml
syu-w Nov 29, 2023
7dd8598
feat(ci): use tox.ini for ci
syu-w Nov 29, 2023
f7ce055
test: allow venv sh shebang
syu-w Nov 30, 2023
cecd533
docs: use starbase readthedocs
syu-w Nov 30, 2023
aaca617
test(docs): delete docs build spread test
syu-w Dec 1, 2023
d48cb9a
chore(linter): fix mypy annotation errors
syu-w Dec 1, 2023
3144a2b
chore(linter): fix pyright annotation errors
syu-w Dec 1, 2023
7d2cd8e
chore(linter): fix docs linter errors
syu-w Dec 1, 2023
a3c4eac
chore(linter): fix yaml linter errors
syu-w Dec 1, 2023
b17987a
Merge branch 'main' into CRAFT-2249-starbase
syu-w Dec 4, 2023
49990bc
chore(ci): sync pre commit config with pyproject
syu-w Dec 4, 2023
33e8ca3
chore(linter): move run_user typing to the top
syu-w Dec 4, 2023
af5594d
chore(linter): fix _create_app return type
syu-w Dec 4, 2023
5ad6554
chore: update the snapcraft workaround comment
syu-w Dec 4, 2023
83ffa4f
chore(linter): increase line length for README
syu-w Dec 4, 2023
aaf57c0
fix: use values for get services
syu-w Dec 4, 2023
bf6a312
test: disable tests that will not work in tox
syu-w Dec 4, 2023
c8c2259
test(spread): add an spread test for shebang
syu-w Dec 5, 2023
d12616a
docs: update the how-to build docs to use tox
syu-w Dec 5, 2023
20a0ab9
chore(ci): fix naming
syu-w Dec 5, 2023
a1fd0ef
chore(deps): use requirements.txt with pyproject.toml
syu-w Dec 5, 2023
a3417f8
chore(snap): use setup.py
syu-w Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rockcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def run() -> int:
return app.run()


def _create_app():
def _create_app(): # noqa: ANN202
syu-w marked this conversation as resolved.
Show resolved Hide resolved
# pylint: disable=import-outside-toplevel
# Import these here so that the script that generates the docs for the
# commands doesn't need to know *too much* of the application.
Expand Down
4 changes: 2 additions & 2 deletions rockcraft/commands/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ListExtensionsCommand(AppCommand, abc.ABC):
)

@overrides
def run(self, parsed_args: argparse.Namespace):
def run(self, parsed_args: argparse.Namespace) -> None:
"""Print the list of available extensions and their bases."""
extension_presentation: dict[str, ExtensionModel] = {}

Expand Down Expand Up @@ -95,7 +95,7 @@ class ExpandExtensionsCommand(AppCommand, abc.ABC):
)

@overrides
def run(self, parsed_args: argparse.Namespace):
def run(self, parsed_args: argparse.Namespace) -> None:
"""Print the project's specification with the extensions expanded."""
project = Project.unmarshal(load_project(Path("rockcraft.yaml")))

Expand Down
5 changes: 4 additions & 1 deletion rockcraft/extensions/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def _apply_extension(
parts[part_name] = parts_snippet[part_name]


def _apply_extension_property(existing_property: Any, extension_property: Any) -> Any:
def _apply_extension_property(
existing_property: list[Any] | dict[str, Any] | None,
extension_property: list[Any] | dict[str, Any],
) -> list[Any] | dict[str, Any] | None:
if existing_property:
# If the property is not scalar, merge them
if isinstance(existing_property, list) and isinstance(extension_property, list):
Expand Down
12 changes: 8 additions & 4 deletions rockcraft/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def _validate_title(cls, title: str | None, values: Mapping[str, Any]) -> str:

@pydantic.validator("build_base", always=True)
@classmethod
def _validate_build_base(cls, build_base: str | None, values: Any) -> str:
def _validate_build_base(
cls, build_base: str | None, values: dict[str, Any]
) -> str:
"""Build-base defaults to the base value if not specified.

:raises ProjectValidationError: If base validation fails.
Expand Down Expand Up @@ -306,7 +308,9 @@ def _validate_parts(cls, item: dict[str, Any]) -> dict[str, Any]:

@pydantic.validator("parts", each_item=True)
@classmethod
def _validate_base_and_overlay(cls, item: dict[str, Any], values) -> dict[str, Any]:
def _validate_base_and_overlay(
cls, item: dict[str, Any], values: dict[str, Any]
) -> dict[str, Any]:
"""Projects with "bare" bases cannot use overlays."""
if values.get("base") == "bare" and part_has_overlay(item):
raise ProjectValidationError(
Expand All @@ -317,7 +321,7 @@ def _validate_base_and_overlay(cls, item: dict[str, Any], values) -> dict[str, A
@pydantic.validator("entrypoint_service")
@classmethod
def _validate_entrypoint_service(
cls, entrypoint_service: str | None, values: Any
cls, entrypoint_service: str | None, values: dict[str, Any]
) -> str | None:
"""Verify that the entrypoint_service exists in the services dict."""
craft_cli.emit.message(
Expand Down Expand Up @@ -398,7 +402,7 @@ def _forbid_env_var_bash_interpolation(
def to_yaml(self) -> str:
"""Dump this project as a YAML string."""

def _repr_str(dumper, data):
def _repr_str(dumper: yaml.SafeDumper, data: str) -> yaml.ScalarNode:
"""Multi-line string representer for the YAML dumper."""
if "\n" in data:
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|")
Expand Down
12 changes: 8 additions & 4 deletions rockcraft/services/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

import contextlib
from pathlib import Path
from typing import cast
from typing import Any, cast

from craft_application import LifecycleService
from craft_archives import repo
from craft_cli import emit
from craft_parts import Features, Step, callbacks
from craft_parts import Features, LifecycleManager, Step, callbacks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ir seems that this can imported only if TYPE_CHECKING?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got:

rockcraft/services/lifecycle.py:35:29: TCH004 Move import `craft_parts.LifecycleManager` out of type-checking block. Import is used for more than type hinting.

from craft_parts.errors import CallbackRegistrationError
from craft_parts.infos import ProjectInfo
from overrides import override

from rockcraft import layers
Expand Down Expand Up @@ -83,7 +84,10 @@ def run(self, step_name: str | None, part_names: list[str] | None = None) -> Non
callbacks.unregister_all()


def _install_package_repositories(package_repositories, lifecycle_manager) -> None:
def _install_package_repositories(
package_repositories: list[dict[str, Any]] | None,
lifecycle_manager: LifecycleManager,
) -> None:
"""Install package repositories in the environment."""
if not package_repositories:
emit.debug("No package repositories specified, none to install.")
Expand All @@ -97,7 +101,7 @@ def _install_package_repositories(package_repositories, lifecycle_manager) -> No
emit.progress("Package repositories installed")


def _install_overlay_repositories(overlay_dir, project_info):
def _install_overlay_repositories(overlay_dir: Path, project_info: ProjectInfo) -> None:
if project_info.base != "bare":
package_repositories = project_info.package_repositories
repo.install_in_root(
Expand Down