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): fix ruff 0.6.0 linting errors #423

Merged
merged 1 commit into from
Aug 19, 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
28 changes: 14 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _create_fake_build_plan(num_infos: int = 1) -> list[models.BuildInfo]:
return [models.BuildInfo("foo", arch, arch, base)] * num_infos


@pytest.fixture()
@pytest.fixture
def features(request) -> dict[str, bool]:
"""Fixture that controls the enabled features.

Expand Down Expand Up @@ -69,7 +69,7 @@ def default_app_metadata() -> craft_application.AppMetadata:
)


@pytest.fixture()
@pytest.fixture
def app_metadata(features) -> craft_application.AppMetadata:
with pytest.MonkeyPatch.context() as m:
m.setattr(metadata, "version", lambda _: "3.14159")
Expand All @@ -82,7 +82,7 @@ def app_metadata(features) -> craft_application.AppMetadata:
)


@pytest.fixture()
@pytest.fixture
def app_metadata_docs(features) -> craft_application.AppMetadata:
with pytest.MonkeyPatch.context() as m:
m.setattr(metadata, "version", lambda _: "3.14159")
Expand All @@ -95,7 +95,7 @@ def app_metadata_docs(features) -> craft_application.AppMetadata:
)


@pytest.fixture()
@pytest.fixture
def fake_project() -> models.Project:
arch = util.get_host_architecture()
return models.Project(
Expand All @@ -116,13 +116,13 @@ def fake_project() -> models.Project:
)


@pytest.fixture()
@pytest.fixture
def fake_build_plan(request) -> list[models.BuildInfo]:
num_infos = getattr(request, "param", 1)
return _create_fake_build_plan(num_infos)


@pytest.fixture()
@pytest.fixture
def full_build_plan(mocker) -> list[models.BuildInfo]:
"""A big build plan with multiple bases and build-for targets."""
host_arch = util.get_host_architecture()
Expand All @@ -142,7 +142,7 @@ def full_build_plan(mocker) -> list[models.BuildInfo]:
return build_plan


@pytest.fixture()
@pytest.fixture
def enable_partitions() -> Iterator[craft_parts.Features]:
"""Enable the partitions feature in craft_parts for the relevant test."""
enable_overlay = craft_parts.Features().enable_overlay
Expand All @@ -152,7 +152,7 @@ def enable_partitions() -> Iterator[craft_parts.Features]:
craft_parts.Features.reset()


@pytest.fixture()
@pytest.fixture
def enable_overlay() -> Iterator[craft_parts.Features]:
"""Enable the overlay feature in craft_parts for the relevant test."""
if not os.getenv("CI") and not shutil.which("fuse-overlayfs"):
Expand All @@ -164,7 +164,7 @@ def enable_overlay() -> Iterator[craft_parts.Features]:
craft_parts.Features.reset()


@pytest.fixture()
@pytest.fixture
def lifecycle_service(
app_metadata, fake_project, fake_services, fake_build_plan, mocker, tmp_path
) -> services.LifecycleService:
Expand Down Expand Up @@ -194,7 +194,7 @@ def lifecycle_service(
return service


@pytest.fixture()
@pytest.fixture
def request_service(app_metadata, fake_services) -> services.RequestService:
"""A working version of the requests service."""
return services.RequestService(app=app_metadata, services=fake_services)
Expand All @@ -208,7 +208,7 @@ def emitter_verbosity(request):
emit.set_mode(reset_verbosity)


@pytest.fixture()
@pytest.fixture
def fake_provider_service_class(fake_build_plan):
class FakeProviderService(services.ProviderService):
def __init__(
Expand All @@ -229,7 +229,7 @@ def __init__(
return FakeProviderService


@pytest.fixture()
@pytest.fixture
def fake_package_service_class():
class FakePackageService(services.PackageService):
def pack(
Expand All @@ -247,7 +247,7 @@ def metadata(self) -> models.BaseMetadata:
return FakePackageService


@pytest.fixture()
@pytest.fixture
def fake_lifecycle_service_class(tmp_path, fake_build_plan):
class FakeLifecycleService(services.LifecycleService):
def __init__(
Expand All @@ -272,7 +272,7 @@ def __init__(
return FakeLifecycleService


@pytest.fixture()
@pytest.fixture
def fake_services(
app_metadata, fake_project, fake_lifecycle_service_class, fake_package_service_class
):
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def pytest_runtest_setup(item: pytest.Item):
pytest.skip("multipass not installed")


@pytest.fixture()
@pytest.fixture
def provider_service(app_metadata, fake_project, fake_build_plan, fake_services):
"""Provider service with install snap disabled for integration tests"""
return provider.ProviderService(
Expand All @@ -63,7 +63,7 @@ def anonymous_remote_build_service(default_app_metadata):
return service


@pytest.fixture()
@pytest.fixture
def snap_safe_tmp_path():
"""A temporary path accessible to snap-confined craft providers.

Expand All @@ -87,7 +87,7 @@ def snap_safe_tmp_path():
yield pathlib.Path(temp_dir)


@pytest.fixture()
@pytest.fixture
def pretend_jammy(mocker) -> None:
"""Pretend we're running on jammy. Used for tests that use destructive mode."""
fake_host = bases.BaseName(name="ubuntu", version="22.04")
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _pre_run(self, dispatcher: craft_cli.Dispatcher) -> None:
self.project_dir = pathlib.Path.cwd()


@pytest.fixture()
@pytest.fixture
def create_app(app_metadata, fake_package_service_class):
def _inner():
# Create a factory without a project, to simulate a real application use
Expand All @@ -52,7 +52,7 @@ def _inner():
return _inner


@pytest.fixture()
@pytest.fixture
def app(create_app):
return create_app()

Expand Down Expand Up @@ -327,7 +327,7 @@ def test_global_environment(
)


@pytest.fixture()
@pytest.fixture
def setup_secrets_project(create_app, monkeypatch, tmp_path):
"""Test the use of build secrets in destructive mode."""

Expand All @@ -348,7 +348,7 @@ def _inner(*, destructive_mode: bool):
return _inner


@pytest.fixture()
@pytest.fixture
def check_secrets_output(tmp_path, capsys):
def _inner():
prime_dir = tmp_path / "prime"
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/commands/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from typing_extensions import override


@pytest.fixture()
@pytest.fixture
def fake_command(app_metadata, fake_services):
class FakeCommand(base.AppCommand):
_run_managed = True
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_needs_project(fake_command, always_load_project):


# region Tests for ExtensibleCommand
@pytest.fixture()
@pytest.fixture
def fake_extensible_cls():
class FakeExtensibleCommand(base.ExtensibleCommand):
name = "fake"
Expand All @@ -108,7 +108,7 @@ def _run(
return FakeExtensibleCommand


@pytest.fixture()
@pytest.fixture
def fake_extensible_child(fake_extensible_cls):
class FakeChild(fake_extensible_cls):
name = "child"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/commands/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def test_pack_run_wrong_step(app_metadata, fake_services):
assert exc_info.value.args[0] == "Step name wrong-command passed to pack command."


@pytest.fixture()
@pytest.fixture
def mock_subprocess_run(mocker):
return mocker.patch.object(subprocess, "run")

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def fake_host_architecture(monkeypatch, request) -> str:
return request.param


@pytest.fixture()
@pytest.fixture
def provider_service(
app_metadata, fake_project, fake_build_plan, fake_services, tmp_path
):
Expand All @@ -41,7 +41,7 @@ def provider_service(
)


@pytest.fixture()
@pytest.fixture
def mock_services(app_metadata, fake_project, fake_package_service_class):
factory = services.ServiceFactory(
app_metadata, project=fake_project, PackageClass=fake_package_service_class
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/git/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)


@pytest.fixture()
@pytest.fixture
def empty_working_directory(tmp_path) -> Iterator[Path]:
cwd = pathlib.Path.cwd()

Expand All @@ -46,7 +46,7 @@ def empty_working_directory(tmp_path) -> Iterator[Path]:
os.chdir(cwd)


@pytest.fixture()
@pytest.fixture
def empty_repository(empty_working_directory) -> Path:
subprocess.run(["git", "init"], check=True)
return cast(Path, empty_working_directory)
Expand Down Expand Up @@ -611,7 +611,7 @@ def test_check_git_repo_for_remote_build_invalid(empty_working_directory):
check_git_repo_for_remote_build(empty_working_directory)


@pytest.fixture()
@pytest.fixture
def patched_cloning_process(mocker):
return mocker.patch(
"craft_parts.utils.os_utils.process_run",
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/launchpad/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
from craft_application.launchpad import Launchpad


@pytest.fixture()
@pytest.fixture
def mock_lplib():
return mock.Mock(**{"me.name": "test_user"})


@pytest.fixture()
@pytest.fixture
def mock_lplib_entry():
return mock.MagicMock(
__class__=lazr.restfulclient.resource.Entry,
resource_type_link="http://blah#this",
)


@pytest.fixture()
@pytest.fixture
def fake_launchpad(mock_lplib):
return Launchpad("testcraft", mock_lplib)
2 changes: 1 addition & 1 deletion tests/unit/launchpad/models/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def new(cls, *args: Any, **kwargs: Any) -> Self:
raise NotImplementedError


@pytest.fixture()
@pytest.fixture
def fake_obj(fake_launchpad, mock_lplib_entry):
return FakeLaunchpadObject(fake_launchpad, mock_lplib_entry)

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/models/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
PARTS_DICT = {"my-part": {"plugin": "nil"}}


@pytest.fixture()
@pytest.fixture
def basic_project():
# pyright doesn't like these types and doesn't have a pydantic plugin like mypy.
# Because of this, we need to silence several errors in these constants.
Expand All @@ -63,13 +63,13 @@ def basic_project():
}


@pytest.fixture()
@pytest.fixture
def basic_project_dict():
"""Provides a modifiable copy of ``BASIC_PROJECT_DICT``"""
return copy.deepcopy(BASIC_PROJECT_DICT)


@pytest.fixture()
@pytest.fixture
def full_project():
return Project.model_validate(
{
Expand Down Expand Up @@ -115,7 +115,7 @@ def full_project():
}


@pytest.fixture()
@pytest.fixture
def full_project_dict():
"""Provides a modifiable copy of ``FULL_PROJECT_DICT``"""
return copy.deepcopy(FULL_PROJECT_DICT)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/remote/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pytest


@pytest.fixture()
@pytest.fixture
def new_dir(tmp_path):
"""Change to a new temporary directory."""

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/remote/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_get_build_id_directory_is_not_a_directory_error():
################


@pytest.fixture()
@pytest.fixture
def stub_directory_tree():
"""Creates a tree of directories and files."""
root_dir = Path("root-dir")
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/services/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def get_mock_callable(**kwargs):
return mock.Mock(spec_set=Callable, **kwargs)


@pytest.fixture()
@pytest.fixture
def mock_project_entry():
return get_mock_lazr_entry(
resource_type="project",
name="craft_test_user-craft-remote-build",
)


@pytest.fixture()
@pytest.fixture
def mock_git_repository():
return get_mock_lazr_entry(
"git_repository",
Expand All @@ -67,7 +67,7 @@ def mock_git_repository():
)


@pytest.fixture()
@pytest.fixture
def fake_launchpad(app_metadata, mock_git_repository, mock_project_entry):
me = mock.Mock(lazr.restfulclient.resource.Entry)
me.name = "craft_test_user"
Expand Down Expand Up @@ -109,7 +109,7 @@ def fake_launchpad(app_metadata, mock_git_repository, mock_project_entry):
return launchpad.Launchpad(app_metadata.name, lp)


@pytest.fixture()
@pytest.fixture
def remote_build_service(app_metadata, fake_services, fake_launchpad):
class FakeRemoteBuildService(services.RemoteBuildService):
RecipeClass = launchpad.models.SnapRecipe
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/services/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _init_lifecycle_manager(self) -> LifecycleManager:
return mock_lcm


@pytest.fixture()
@pytest.fixture
def fake_parts_lifecycle(
app_metadata, fake_project, fake_services, tmp_path, fake_build_plan
):
Expand Down
Loading
Loading