Skip to content
Snippets Groups Projects
Verified Commit e26f89d3 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

Update and run pre-commit configuration to format properly code

The hook was not installed in my repository.

Refs. sysadm-environment#4724
parent 9759150c
No related branches found
No related tags found
No related merge requests found
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: check-json
- id: check-yaml
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==22.3.23]
additional_dependencies: [flake8-bugbear==22.9.23]
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.2
hooks:
- id: codespell
name: Check source code spelling
args: [-L crate]
stages: [commit]
- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy
args: [scripts]
pass_filenames: false
language: system
types: [python]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/python/black
rev: 22.3.0
rev: 22.10.0
hooks:
- id: black
......@@ -130,7 +130,9 @@ def from_tag_to_version(version: str) -> str:
return version.lstrip("v")
def list_impacted_apps(apps_dir: pathlib.Path, application: str, version: str) -> Iterator[str]:
def list_impacted_apps(
apps_dir: pathlib.Path, application: str, version: str
) -> Iterator[str]:
"""List all apps whose constraint does not match `application==version.`.
Expectedly, only applications who have `application` in their
......@@ -140,11 +142,11 @@ def list_impacted_apps(apps_dir: pathlib.Path, application: str, version: str) -
app_module = from_application_to_module(application)
version = from_tag_to_version(version)
for req_file in sorted(apps_dir.glob(f"*/{requirements_frozen}")):
with open(req_file, 'r') as f:
with open(req_file, "r") as f:
for line in f:
line = line.rstrip()
if '==' in line: # we ignore the `@` case for now
module, version_ = line.rstrip().split('==')
if "==" in line: # we ignore the `@` case for now
module, version_ = line.rstrip().split("==")
if module == app_module:
if version == version_:
# Application is already built for the right version, stop
......@@ -160,8 +162,12 @@ def list_apps(apps_dir: pathlib.Path) -> Iterator[str]:
@app.command("list")
@click.option("-a", "--application", "application", default=None, help="Application name")
@click.option("-v", "--version", "version", default=None, help="Version of the application")
@click.option(
"-a", "--application", "application", default=None, help="Application name"
)
@click.option(
"-v", "--version", "version", default=None, help="Version of the application"
)
@click.pass_context
def list(ctx, application: str, version: str) -> None:
"""With no parameters, list all known applications with a requirements.txt. With
......@@ -200,9 +206,7 @@ def compute_information(current_values: Dict):
def compute_yaml(updated_information: Dict[str, Dict[str, str]]) -> Dict[str, str]:
"""Computes the yaml dict to serialize in the values...yaml file.
"""
"""Computes the yaml dict to serialize in the values...yaml file."""
yaml_dict = {}
for image_name, info in updated_information.items():
yaml_dict[f"{image_name}_image"] = info["image"]
......@@ -212,8 +216,11 @@ def compute_yaml(updated_information: Dict[str, Dict[str, str]]) -> Dict[str, st
@app.command("update-values")
@click.option("-v", "--values-filepath",
help="Path to file swh-charts:/values-swh-application-versions.yaml")
@click.option(
"-v",
"--values-filepath",
help="Path to file swh-charts:/values-swh-application-versions.yaml",
)
@click.pass_context
def update_values(ctx, values_filepath: str) -> None:
"""Update docker image version in swh-charts:values-swh-application-versions.yaml
......@@ -221,7 +228,7 @@ def update_values(ctx, values_filepath: str) -> None:
"""
with open(values_filepath, 'r') as f:
with open(values_filepath, "r") as f:
yml_dict = yaml.safe_load(f)
current_information = compute_information(yml_dict)
......@@ -269,7 +276,7 @@ def update_values(ctx, values_filepath: str) -> None:
updated_information[image_name] = info
with open(values_filepath, 'w') as f:
with open(values_filepath, "w") as f:
yaml_dict = compute_yaml(updated_information)
f.write(yaml.dump(yaml_dict))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment