Skip to content

Commit

Permalink
Merge pull request #960 from projectsyn/deps/black-24
Browse files Browse the repository at this point in the history
Update dependency black to v24
  • Loading branch information
simu authored May 13, 2024
2 parents 17b4160 + 5a10229 commit 3224a1c
Show file tree
Hide file tree
Showing 33 changed files with 59 additions and 53 deletions.
1 change: 1 addition & 0 deletions commodore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Commodore. Build dynamic inventories and compile catalogs with Kapitan
"""

from pathlib import Path as P
from importlib_metadata import version

Expand Down
1 change: 1 addition & 0 deletions commodore/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper module to run not-installed version (via ``python3 -m commodore``)
"""

from .cli import main

if __name__ == "__main__":
Expand Down
2 changes: 0 additions & 2 deletions commodore/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def _is_semantic_diff_kapitan_029_030(win: tuple[str, str]) -> bool:
def _kapitan_029_030_difffunc(
before_text: str, after_text: str, fromfile: str = "", tofile: str = ""
) -> tuple[Iterable[str], bool]:

diff_lines, _ = _ignore_yaml_formatting_difffunc(
before_text, after_text, fromfile, tofile
)
Expand All @@ -198,7 +197,6 @@ def _kapitan_029_030_difffunc(
def _ignore_yaml_formatting_difffunc(
before_text: str, after_text: str, fromfile: str = "", tofile: str = ""
) -> tuple[list[str], bool]:

before_objs = sorted(yaml.safe_load_all(before_text), key=K8sObject)
before_sorted_lines = yaml.dump_all(before_objs, Dumper=IndentedListDumper).split(
"\n"
Expand Down
1 change: 1 addition & 0 deletions commodore/cli/catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Commands which interact with cluster catalogs"""

from __future__ import annotations

import click
Expand Down
1 change: 1 addition & 0 deletions commodore/cli/component.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Commands which interact with components"""

from __future__ import annotations

from collections.abc import Iterable
Expand Down
1 change: 1 addition & 0 deletions commodore/cli/inventory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Commands which interact with a Commodore (reclass) inventory"""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions commodore/cli/oidc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Commands which expose Commodore's OIDC login support"""

import click

from commodore.config import Config
Expand Down
1 change: 1 addition & 0 deletions commodore/cli/options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Click options which are reused for multiple commands"""

import click

from commodore.config import Config
Expand Down
1 change: 1 addition & 0 deletions commodore/cli/package.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Commands which interact with config packages"""

from __future__ import annotations

from collections.abc import Iterable
Expand Down
1 change: 0 additions & 1 deletion commodore/dependency_mgmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def create_package_symlink(cfg, pname: str, package: Package):


def fetch_components(cfg: Config):

"""
Download all components required by target.
Expand Down
2 changes: 1 addition & 1 deletion commodore/dependency_mgmt/jsonnet_bundler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def jsonnet_dependencies(config: Config) -> Iterable:
"""
dependencies = []

for (_, component) in sorted(config.get_components().items()):
for _, component in sorted(config.get_components().items()):
dependencies.append(
{
"source": {
Expand Down
3 changes: 1 addition & 2 deletions commodore/dependency_templater.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def __init__(

@classmethod
@abstractmethod
def from_existing(cls, config: Config, path: Path):
...
def from_existing(cls, config: Config, path: Path): ...

@classmethod
def _base_from_existing(cls, config: Config, path: Path, deptype: str):
Expand Down
2 changes: 1 addition & 1 deletion commodore/gitrepo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def checkout(self, version: Optional[str] = None):
def _check_conflicts(self):
"""Check for conflicts in index. Raise `MergeConflict` for the first conflict
found."""
for (path, blobs) in self.repo.index.unmerged_blobs().items():
for path, blobs in self.repo.index.unmerged_blobs().items():
for stage, b in blobs:
if stage != 0:
raise MergeConflict(path)
Expand Down
3 changes: 1 addition & 2 deletions commodore/gitrepo/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
class DiffFunc(Protocol):
def __call__(
self, before_text: str, after_text: str, fromfile: str = "", tofile: str = ""
) -> tuple[Iterable[str], bool]:
...
) -> tuple[Iterable[str], bool]: ...


def _colorize_diff(line: str) -> str:
Expand Down
6 changes: 2 additions & 4 deletions commodore/inventory/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@


class LintFunc(Protocol):
def __call__(self, file: Path, filecontents: dict[str, Any]) -> int:
...
def __call__(self, file: Path, filecontents: dict[str, Any]) -> int: ...


class Linter:
@abc.abstractmethod
def __call__(
self, config: Config, path: Path, ignore_patterns: tuple[str, ...] = ()
) -> int:
...
) -> int: ...


class ComponentSpecLinter(Linter):
Expand Down
3 changes: 1 addition & 2 deletions commodore/postprocess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def __call__(
filterid: str,
path: P,
**filterargs: str,
):
...
): ...


ValidateFunc = Callable[[Config, Component, str, dict], dict]
Expand Down
51 changes: 25 additions & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pytest = "8.2.0"
pytest-xdist = "3.6.1"
pytest-benchmark = "4.0.0"
responses = "0.25.0"
black = "23.12.1"
black = "24.4.2"
pyfakefs = "5.5.0"
pytest-cov = "5.0.0"
pylint = "3.1.0"
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
See the pytest docs for more details:
https://docs.pytest.org/en/latest/how-to/fixtures.html#scope-sharing-fixtures-across-classes-modules-packages-or-session
"""

from __future__ import annotations

import os
Expand All @@ -21,8 +22,7 @@


class RunnerFunc(Protocol):
def __call__(self, args: list[str]) -> Result:
...
def __call__(self, args: list[str]) -> Result: ...


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_catalog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests for catalog internals
"""

from __future__ import annotations

import os
Expand Down Expand Up @@ -603,7 +604,6 @@ def test_catalog_list(
],
)
def test_catalog_list_parameters(config: Config, tenant: str, sort_by: str):

params = {}

if tenant != "":
Expand Down
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests for command line interface (CLI)
"""

from subprocess import call


Expand Down
1 change: 1 addition & 0 deletions tests/test_component_compile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests for component compile command
"""

import shutil
import os

Expand Down
1 change: 1 addition & 0 deletions tests/test_component_template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests for component new command
"""

from __future__ import annotations

import json
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dependency_mgmt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit-tests for dependency management
"""

from __future__ import annotations

import os
Expand Down Expand Up @@ -519,7 +520,6 @@ def test_verify_component_version_overrides(cluster_params: dict, expected: str)
def _setup_packages(
upstream_path: Path, packages: list[str]
) -> dict[str, DependencySpec]:

package_specs = {}

for p in packages:
Expand Down
1 change: 1 addition & 0 deletions tests/test_dependency_mgmt_version_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
functionality of `_read_versions()` was originally implemented directly in
`_read_components()`.
"""

from __future__ import annotations

from unittest.mock import patch
Expand Down
5 changes: 1 addition & 4 deletions tests/test_dependency_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def test_ensure_branch_no_repo(tmp_path: Path, config: Config):


def _setup_gh_get_responses(has_open_pr: bool, clone_url: str = ""):

with open(DATA_DIR / "projectsyn-package-foo-response.json", encoding="utf-8") as f:
resp = json.load(f)
if clone_url:
Expand Down Expand Up @@ -582,8 +581,7 @@ def test_message_body(tmp_path: Path, raw_message: Union[str, bytes], expected:
assert dependency_syncer.message_body(c) == expected


class Foo:
...
class Foo: ...


@pytest.mark.parametrize(
Expand Down Expand Up @@ -617,7 +615,6 @@ def test_maybe_pause(
pause_seconds: int,
expected_pause: bool,
):

start = datetime.datetime.now()
dependency_syncer._maybe_pause(
update_count, pr_batch_size, datetime.timedelta(seconds=pause_seconds)
Expand Down
1 change: 1 addition & 0 deletions tests/test_gitrepo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit-tests for git
"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit-tests for helpers
"""

from __future__ import annotations

import os
Expand Down
4 changes: 2 additions & 2 deletions tests/test_inventory_lint_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ def _setup_directory(tmp_path: Path):
assert len(skip_direntries) == len(SKIP_FILECONTENTS)

expected_errcount = 0
for (idx, (filecontents, eec)) in enumerate(LINT_FILECONTENTS):
for idx, (filecontents, eec) in enumerate(LINT_FILECONTENTS):
dentry = lint_direntries[idx]
os.makedirs(dentry.parent, exist_ok=True)
yaml_dump(filecontents, dentry)
# these should be skipped
yaml_dump(filecontents, tmp_path / f".{idx}.yml")
expected_errcount += eec
for (idx, (filecontents, _)) in enumerate(SKIP_FILECONTENTS):
for idx, (filecontents, _) in enumerate(SKIP_FILECONTENTS):
dentry = skip_direntries[idx]
os.makedirs(dentry.parent, exist_ok=True)
_dump_skip_file(filecontents, dentry)
Expand Down
1 change: 1 addition & 0 deletions tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit-tests for login
"""

from __future__ import annotations

from unittest.mock import patch
Expand Down
1 change: 1 addition & 0 deletions tests/test_postprocess.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests for postprocessing
"""

import os

import click
Expand Down
1 change: 1 addition & 0 deletions tests/test_tokencache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit-tests for tokencache
"""

import json

from xdg.BaseDirectory import xdg_cache_home
Expand Down
Loading

0 comments on commit 3224a1c

Please sign in to comment.