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

style(lint): move from black to ruff #1960

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion charmcraft/application/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Charmcraft commands."""

import craft_application

from charmcraft.application.commands.analyse import Analyse, Analyze
Expand Down Expand Up @@ -109,7 +110,8 @@ def fill_command_groups(app: craft_application.Application) -> None:
],
)
app.add_command_group(
"Extensions", [ExpandExtensionsCommand, ExtensionsCommand, ListExtensionsCommand]
"Extensions",
[ExpandExtensionsCommand, ExtensionsCommand, ListExtensionsCommand],
)
app.add_command_group(
"Other",
Expand Down
1 change: 1 addition & 0 deletions charmcraft/application/commands/analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Command for analysing a charm."""

import argparse
import json
import pathlib
Expand Down
1 change: 1 addition & 0 deletions charmcraft/application/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Base command for Charmcraft commands."""

from __future__ import annotations

import craft_application.commands
Expand Down
1 change: 1 addition & 0 deletions charmcraft/application/commands/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# For further info, check https://github.com/canonical/charmcraft

"""Infrastructure for the 'extensions' command."""

import argparse
from textwrap import dedent

Expand Down
5 changes: 4 additions & 1 deletion charmcraft/application/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# For further info, check https://github.com/canonical/charmcraft

"""Infrastructure for the 'init' command."""

import argparse
import os
import pathlib
Expand Down Expand Up @@ -130,7 +131,9 @@ class InitCommand(base.CharmcraftCommand):

def fill_parser(self, parser):
"""Specify command's specific parameters."""
parser.add_argument("--name", help="The name of the charm; defaults to the directory name")
parser.add_argument(
"--name", help="The name of the charm; defaults to the directory name"
)
parser.add_argument(
"--author",
help="The charm author; defaults to the current user name per GECOS",
Expand Down
11 changes: 9 additions & 2 deletions charmcraft/application/commands/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""craft-application based lifecycle commands."""

from __future__ import annotations

import pathlib
Expand Down Expand Up @@ -171,14 +172,20 @@ def run_managed(self, parsed_args: argparse.Namespace) -> bool:
# Always use a runner on non-Linux platforms.
# Craft-parts is not designed to work on non-posix platforms, and most
# notably here, the bundle plugin doesn't work on Windows.
if sys.platform == "linux" and charmcraft_yaml and charmcraft_yaml.get("type") == "bundle":
if (
sys.platform == "linux"
and charmcraft_yaml
and charmcraft_yaml.get("type") == "bundle"
):
return False

return super().run_managed(parsed_args)

def _update_charm_libs(self) -> None:
"""Update charm libs attached to the project."""
craft_cli.emit.progress("Checking that charmlibs match 'charmcraft.yaml' values")
craft_cli.emit.progress(
"Checking that charmlibs match 'charmcraft.yaml' values"
)
project = cast(models.CharmcraftProject, self._services.project)
libs_svc = cast(services.CharmLibsService, self._services.charm_libs)
installable_libs: list[models.CharmLib] = []
Expand Down
21 changes: 16 additions & 5 deletions charmcraft/application/commands/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Build a charm remotely on Launchpad."""

import argparse
import os
import pathlib
Expand Down Expand Up @@ -63,7 +64,9 @@ class RemoteBuild(ExtensibleCommand):

@override
def _fill_parser(self, parser: argparse.ArgumentParser) -> None:
parser.add_argument("--recover", action="store_true", help="recover an interrupted build")
parser.add_argument(
"--recover", action="store_true", help="recover an interrupted build"
)
parser.add_argument(
"--launchpad-accept-public-upload",
action="store_true",
Expand Down Expand Up @@ -121,7 +124,9 @@ def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: #
emit.progress(f"Recovering build {build_id}")
builds = builder.resume_builds(build_id)
else:
emit.progress("Starting new build. It may take a while to upload large projects.")
emit.progress(
"Starting new build. It may take a while to upload large projects."
)
builds = builder.start_builds(project_dir)

try:
Expand All @@ -138,7 +143,9 @@ def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: #
builder.cleanup()
return returncode

def _monitor_and_complete(self, build_id: str | None, builds: Collection[Build]) -> int:
def _monitor_and_complete(
self, build_id: str | None, builds: Collection[Build]
) -> int:
builder = self._services.remote_build
emit.progress("Monitoring build")
try:
Expand Down Expand Up @@ -168,10 +175,14 @@ def _monitor_and_complete(self, build_id: str | None, builds: Collection[Build])
emit.progress("; ".join(progress_parts))
except TimeoutError:
if build_id:
resume_command = f"{self._app.name} remote-build --recover --build-id={build_id}"
resume_command = (
f"{self._app.name} remote-build --recover --build-id={build_id}"
)
else:
resume_command = f"{self._app.name} remote-build --recover"
emit.message(f"Timed out waiting for build.\nTo resume, run {resume_command!r}")
emit.message(
f"Timed out waiting for build.\nTo resume, run {resume_command!r}"
)
return 75 # Temporary failure

emit.progress(f"Fetching {len(builds)} build logs...")
Expand Down
Loading
Loading