From 12ce4a22258fd92d3dda4e06d806f0ba74f7902f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:16:53 +0000 Subject: [PATCH] Update all minor versions (master) (minor) (#1186) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update all minor versions * Add Ruff --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Stéphane Brunner --- .github/workflows/main.yaml | 2 - .pre-commit-config.yaml | 31 +++++----- Makefile | 2 +- acceptance_tests/.prospector.yaml | 17 +----- acceptance_tests/acceptance/__init__.py | 3 + acceptance_tests/acceptance/file/conftest.py | 8 +-- .../acceptance/file/test_workflow.py | 3 +- .../acceptance/inline/conftest.py | 8 +-- .../acceptance/inline/test_workflow.py | 3 +- .../acceptance/normal/conftest.py | 10 ++-- .../acceptance/normal/test_workflow.py | 3 +- acceptance_tests/package-lock.json | 38 ++++++------ acceptance_tests/package.json | 2 +- acceptance_tests/poetry.lock | 59 ++++++++++++++----- acceptance_tests/pyproject.toml | 6 +- app/.bandit.yaml | 3 - app/.prospector.yaml | 19 ++++-- app/gunicorn.conf.py | 3 - app/poetry.lock | 59 ++++++++++++++----- app/pyproject.toml | 6 +- app/shared_config_manager/app.py | 2 + .../scripts/shared_config_slave.py | 3 +- app/shared_config_manager/security.py | 9 +-- app/shared_config_manager/services.py | 2 +- app/shared_config_manager/slave_status.py | 2 + app/shared_config_manager/sources/base.py | 6 +- app/shared_config_manager/sources/git.py | 2 + app/shared_config_manager/sources/mode.py | 4 ++ app/shared_config_manager/sources/rclone.py | 2 + app/shared_config_manager/sources/registry.py | 14 +++-- app/shared_config_manager/sources/rsync.py | 2 + app/shared_config_manager/sources/ssh.py | 2 + .../template_engines/__init__.py | 1 + .../template_engines/base.py | 7 ++- .../template_engines/mako.py | 4 +- .../template_engines/shell.py | 2 + pyproject.toml | 10 +--- 37 files changed, 215 insertions(+), 144 deletions(-) delete mode 100644 app/.bandit.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e2dbb606..38df0db2 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -41,8 +41,6 @@ jobs: key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} restore-keys: "pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}\npre-commit-" - run: pre-commit run --all-files - env: - SKIP: poetry-lock,isort - run: git diff --exit-code --patch > /tmp/pre-commit.patch || true if: failure() - uses: actions/upload-artifact@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9280e0fc..e812f444 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,26 +64,25 @@ repos: rev: v0.1.8 hooks: - id: ripsecrets - - repo: https://github.com/PyCQA/autoflake - rev: v2.3.1 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.1 hooks: - - id: autoflake - - repo: https://github.com/asottile/pyupgrade - rev: v3.19.0 - hooks: - - id: pyupgrade + - id: ruff-format args: - - --py310-plus - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - - repo: https://github.com/psf/black - rev: 24.10.0 + - --line-length=110 + - repo: https://github.com/PyCQA/prospector + rev: v1.13.3 hooks: - - id: black + - id: prospector args: - - --line-length=110 + - --profile=app/.prospector.yaml + - --tool=ruff + - --die-on-tool-error + - --output-format=pylint + additional_dependencies: + - prospector-profile-duplicated==1.8.0 # pypi + - prospector-profile-utils==1.13.0 # pypi + - ruff==0.8.1 # pypi - repo: https://github.com/sbrunner/jsonschema-validator rev: 0.3.2 hooks: diff --git a/Makefile b/Makefile index 515a4f0c..1fa6a7f1 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ checks: prospector acceptance-prospector ## Run the checks .PHONY: acceptance-prospector acceptance-prospector: build-acceptance ## Run Prospector on acceptance docker run --rm --volume=${PWD}/acceptance_tests:/acceptance_tests --volume=${PWD}/acceptance_tests:/acceptance_tests/acceptance_tests $(DOCKER_BASE)-acceptance:$(DOCKER_TAG) \ - prospector --output=pylint --die-on-tool-error acceptance_tests + prospector --output=pylint --die-on-tool-error --without=ruff acceptance_tests .PHONY: prospector prospector: build-checker ## Run Prospector diff --git a/acceptance_tests/.prospector.yaml b/acceptance_tests/.prospector.yaml index ec97a189..7ea72434 100644 --- a/acceptance_tests/.prospector.yaml +++ b/acceptance_tests/.prospector.yaml @@ -1,18 +1,5 @@ inherits: - - utils:base - - utils:no-design-checks + - utils:base-less-strict + - utils:c2cwsgiutils - utils:fix - duplicated - -pylint: - disable: - - missing-timeout # Done by c2cwsgiutils - -mypy: - run: false - -bandit: - run: false - -pyroma: - run: false diff --git a/acceptance_tests/acceptance/__init__.py b/acceptance_tests/acceptance/__init__.py index 269cd9f2..d8a7942f 100644 --- a/acceptance_tests/acceptance/__init__.py +++ b/acceptance_tests/acceptance/__init__.py @@ -4,6 +4,8 @@ def wait_sync(app_connection, name, hash_): + """Wait for the sync to be done.""" + def what(): status = app_connection.get_json("1/status", headers={"X-Scm-Secret": "changeme"}) for slave_name, slave in status["slaves"].items(): @@ -39,4 +41,5 @@ def what(): def get_hash(cwd): + """Get the hash of the current git repository.""" return subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=cwd).decode("utf-8").strip() diff --git a/acceptance_tests/acceptance/file/conftest.py b/acceptance_tests/acceptance/file/conftest.py index 43f7772a..0d1ac3e8 100644 --- a/acceptance_tests/acceptance/file/conftest.py +++ b/acceptance_tests/acceptance/file/conftest.py @@ -7,9 +7,7 @@ @pytest.fixture(scope="package") def composition(request): - """ - Fixture that will wait that the composition is started, used for all the tests. - """ + """Fixture that will wait that the composition is started, used for all the tests.""" del request for slave in ("api",): path = os.path.join("/config", slave) @@ -22,8 +20,6 @@ def composition(request): @pytest.fixture def app_connection(composition): # pylint: disable=redefined-outer-name - """ - Fixture that returns a connection to a running batch container. - """ + """Fixture that returns a connection to a running batch container.""" del composition return Connection(base_url="http://api_file:8080/scm/", origin="http://example.com/") diff --git a/acceptance_tests/acceptance/file/test_workflow.py b/acceptance_tests/acceptance/file/test_workflow.py index 4c67d3f7..1d67bcf5 100644 --- a/acceptance_tests/acceptance/file/test_workflow.py +++ b/acceptance_tests/acceptance/file/test_workflow.py @@ -3,9 +3,10 @@ import os import yaml -from acceptance import get_hash, wait_sync from c2cwsgiutils.acceptance.connection import Connection +from acceptance import get_hash, wait_sync + def test_ok(app_connection: Connection): test_git_hash = get_hash("/repos/test_git") diff --git a/acceptance_tests/acceptance/inline/conftest.py b/acceptance_tests/acceptance/inline/conftest.py index 81376a0d..510c4875 100644 --- a/acceptance_tests/acceptance/inline/conftest.py +++ b/acceptance_tests/acceptance/inline/conftest.py @@ -7,9 +7,7 @@ @pytest.fixture(scope="package") def composition(request): - """ - Fixture that will wait that the composition is started, used for all the tests. - """ + """Fixture that will wait that the composition is started, used for all the tests.""" del request for slave in ("api",): path = os.path.join("/config", slave) @@ -22,8 +20,6 @@ def composition(request): @pytest.fixture def app_connection(composition): # pylint: disable=redefined-outer-name - """ - Fixture that returns a connection to a running batch container. - """ + """Fixture that returns a connection to a running batch container.""" del composition return Connection(base_url="http://api_inline:8080/scm/", origin="http://example.com/") diff --git a/acceptance_tests/acceptance/inline/test_workflow.py b/acceptance_tests/acceptance/inline/test_workflow.py index 4affb60f..d0581bb3 100644 --- a/acceptance_tests/acceptance/inline/test_workflow.py +++ b/acceptance_tests/acceptance/inline/test_workflow.py @@ -2,9 +2,10 @@ import os -from acceptance import get_hash, wait_sync from c2cwsgiutils.acceptance.connection import Connection +from acceptance import get_hash, wait_sync + def test_ok(app_connection: Connection): test_git_hash = get_hash("/repos/test_git") diff --git a/acceptance_tests/acceptance/normal/conftest.py b/acceptance_tests/acceptance/normal/conftest.py index c7572114..d2b7429c 100644 --- a/acceptance_tests/acceptance/normal/conftest.py +++ b/acceptance_tests/acceptance/normal/conftest.py @@ -10,6 +10,8 @@ def wait_slaves(): + """Wait for the slaves to be up.""" + def what() -> bool: r = requests.get("http://api:8080/scm/1/status", headers={"X-Scm-Secret": "changeme"}) if r.status_code == 200: @@ -41,9 +43,7 @@ def what() -> bool: @pytest.fixture(scope="package") def composition(request): - """ - Fixture that will wait that the composition is started, used for all the tests. - """ + """Fixture that will wait that the composition is started, used for all the tests.""" del request for slave in ("api", "slave", "slave-others"): path = os.path.join("/config", slave) @@ -57,8 +57,6 @@ def composition(request): @pytest.fixture def app_connection(composition: None): # pylint: disable=redefined-outer-name - """ - Fixture that returns a connection to a running batch container. - """ + """Fixture that returns a connection to a running batch container.""" del composition return Connection(base_url="http://api:8080/scm/", origin="http://example.com/") diff --git a/acceptance_tests/acceptance/normal/test_workflow.py b/acceptance_tests/acceptance/normal/test_workflow.py index d37aa296..dbeaac26 100644 --- a/acceptance_tests/acceptance/normal/test_workflow.py +++ b/acceptance_tests/acceptance/normal/test_workflow.py @@ -6,9 +6,10 @@ import pytest import requests -from acceptance import get_hash, wait_sync from c2cwsgiutils.acceptance.connection import Connection +from acceptance import get_hash, wait_sync + @pytest.fixture() def git_source(app_connection: Connection): diff --git a/acceptance_tests/package-lock.json b/acceptance_tests/package-lock.json index 31568592..079a0c02 100644 --- a/acceptance_tests/package-lock.json +++ b/acceptance_tests/package-lock.json @@ -6,7 +6,7 @@ "": { "dependencies": { "commander": "12.1.0", - "puppeteer": "23.6.1" + "puppeteer": "23.9.0" } }, "node_modules/@babel/code-frame": { @@ -33,12 +33,12 @@ } }, "node_modules/@puppeteer/browsers": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.4.0.tgz", - "integrity": "sha512-x8J1csfIygOwf6D6qUAZ0ASk3z63zPb7wkNeHRerCMh82qWKUrOgkuP005AJC8lDL6/evtXETGEJVcwykKT4/g==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.4.1.tgz", + "integrity": "sha512-0kdAbmic3J09I6dT8e9vE2JOCSt13wHCW5x/ly8TSt2bDtuIWe2TgLZZDHdcziw9AVCzflMAXCrVyRIhIs44Ng==", "license": "Apache-2.0", "dependencies": { - "debug": "^4.3.6", + "debug": "^4.3.7", "extract-zip": "^2.0.1", "progress": "^2.0.3", "proxy-agent": "^6.4.0", @@ -379,9 +379,9 @@ } }, "node_modules/devtools-protocol": { - "version": "0.0.1354347", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1354347.tgz", - "integrity": "sha512-BlmkSqV0V84E2WnEnoPnwyix57rQxAM5SKJjf4TbYOCGLAWtz8CDH8RIaGOjPgPCXo2Mce3kxSY497OySidY3Q==", + "version": "0.0.1367902", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1367902.tgz", + "integrity": "sha512-XxtPuC3PGakY6PD7dG66/o8KwJ/LkH2/EKe19Dcw58w53dv4/vSQEkn/SzuyhHE2q4zPgCkxQBxus3VV4ql+Pg==", "license": "BSD-3-Clause" }, "node_modules/emoji-regex": { @@ -868,17 +868,17 @@ } }, "node_modules/puppeteer": { - "version": "23.6.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.6.1.tgz", - "integrity": "sha512-8+ALGQgwXd3P/tGcuSsxTPGDaOQIjcDIm04I5hpWZv/PiN5q8bQNHRUyfYrifT+flnM9aTWCP7tLEzuB6SlIgA==", + "version": "23.9.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.9.0.tgz", + "integrity": "sha512-WfB8jGwFV+qrD9dcJJVvWPFJBU6kxeu2wxJz9WooDGfM3vIiKLgzImEDBxUQnCBK/2cXB3d4dV6gs/LLpgfLDg==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@puppeteer/browsers": "2.4.0", + "@puppeteer/browsers": "2.4.1", "chromium-bidi": "0.8.0", "cosmiconfig": "^9.0.0", - "devtools-protocol": "0.0.1354347", - "puppeteer-core": "23.6.1", + "devtools-protocol": "0.0.1367902", + "puppeteer-core": "23.9.0", "typed-query-selector": "^2.12.0" }, "bin": { @@ -889,15 +889,15 @@ } }, "node_modules/puppeteer-core": { - "version": "23.6.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.6.1.tgz", - "integrity": "sha512-DoNLAzQfGklPauEn33N4h9cM9GubJSINEn+AUMwAXwW159Y9JLk5y34Jsbv4c7kG8P0puOYWV9leu2siMZ/QpQ==", + "version": "23.9.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.9.0.tgz", + "integrity": "sha512-hLVrav2HYMVdK0YILtfJwtnkBAwNOztUdR4aJ5YKDvgsbtagNr6urUJk9HyjRA9e+PaLI3jzJ0wM7A4jSZ7Qxw==", "license": "Apache-2.0", "dependencies": { - "@puppeteer/browsers": "2.4.0", + "@puppeteer/browsers": "2.4.1", "chromium-bidi": "0.8.0", "debug": "^4.3.7", - "devtools-protocol": "0.0.1354347", + "devtools-protocol": "0.0.1367902", "typed-query-selector": "^2.12.0", "ws": "^8.18.0" }, diff --git a/acceptance_tests/package.json b/acceptance_tests/package.json index eced1ab1..e1e5bdcf 100644 --- a/acceptance_tests/package.json +++ b/acceptance_tests/package.json @@ -1,7 +1,7 @@ { "dependencies": { "commander": "12.1.0", - "puppeteer": "23.6.1" + "puppeteer": "23.9.0" }, "type": "module" } diff --git a/acceptance_tests/poetry.lock b/acceptance_tests/poetry.lock index 23d85a36..9c6e576d 100644 --- a/acceptance_tests/poetry.lock +++ b/acceptance_tests/poetry.lock @@ -1263,18 +1263,17 @@ twisted = ["twisted"] [[package]] name = "prospector" -version = "1.12.1" +version = "1.13.3" description = "Prospector is a tool to analyse Python code by aggregating the result of other tools." optional = false python-versions = "<4.0,>=3.9" files = [ - {file = "prospector-1.12.1-py3-none-any.whl", hash = "sha256:e2440b51f40626cbaea80edd97263d8c0a71a79e729415fb505096d4d39e2287"}, - {file = "prospector-1.12.1.tar.gz", hash = "sha256:b9bb4bcdd77b943c597ee4f374960e851cdd2a0b4b60eaeeaf0da465facafc60"}, + {file = "prospector-1.13.3-py3-none-any.whl", hash = "sha256:e7261c222ba54bc8aef8c9e31b2dcf5ed2a656c9b76fc0cceab294cd5ec3db6b"}, + {file = "prospector-1.13.3.tar.gz", hash = "sha256:36ccb13f69aa27c5c4682afd4cc46219b9e0c80723e30dc64ff30c71f7b877a1"}, ] [package.dependencies] dodgy = ">=0.2.1,<0.3.0" -flake8 = "*" GitPython = ">=3.1.27,<4.0.0" mccabe = ">=0.7.0,<0.8.0" packaging = "*" @@ -1287,40 +1286,45 @@ pylint-celery = "0.3" pylint-django = ">=2.6.1" pylint-flask = "0.6" PyYAML = "*" -requirements-detector = ">=1.3.1" +requirements-detector = ">=1.3.2" +ruff = {version = "*", optional = true, markers = "extra == \"with-ruff\" or extra == \"with_everything\""} setoptconf-tmp = ">=0.3.1,<0.4.0" toml = ">=0.10.2,<0.11.0" [package.extras] with-bandit = ["bandit (>=1.5.1)"] -with-everything = ["bandit (>=1.5.1)", "mypy (>=0.600)", "pyright (>=1.1.3)", "pyroma (>=2.4)", "vulture (>=1.5)"] +with-everything = ["bandit (>=1.5.1)", "mypy (>=0.600)", "pyright (>=1.1.3)", "pyroma (>=2.4)", "ruff", "vulture (>=1.5)"] with-mypy = ["mypy (>=0.600)"] with-pyright = ["pyright (>=1.1.3)"] with-pyroma = ["pyroma (>=2.4)"] +with-ruff = ["ruff"] with-vulture = ["vulture (>=1.5)"] [[package]] name = "prospector-profile-duplicated" -version = "1.6.0" +version = "1.8.1" description = "Profile that can be used to disable the duplicated or conflict rules between Prospector and other tools" optional = false python-versions = "*" files = [ - {file = "prospector_profile_duplicated-1.6.0-py2.py3-none-any.whl", hash = "sha256:bf6a6aae0c7de48043b95e4d42e23ccd090c6c7115b6ee8c8ca472ffb1a2022b"}, - {file = "prospector_profile_duplicated-1.6.0.tar.gz", hash = "sha256:9c2d541076537405e8b2484cb6222276a2df17492391b6af1b192695770aab83"}, + {file = "prospector_profile_duplicated-1.8.1-py2.py3-none-any.whl", hash = "sha256:a3c23517b9749ea0e61cc9b23d1526752c1eeb6c899cd0d9ec1fa77b1f373a49"}, + {file = "prospector_profile_duplicated-1.8.1.tar.gz", hash = "sha256:a08fa1f5aa77bdbc908b0c4f66b2bdb306aba10c44c5db51e389cd5cf79bda04"}, ] [[package]] name = "prospector-profile-utils" -version = "1.9.1" +version = "1.14.0" description = "Some utility Prospector profiles." optional = false -python-versions = "*" +python-versions = "<4.0,>=3.9" files = [ - {file = "prospector_profile_utils-1.9.1-py2.py3-none-any.whl", hash = "sha256:b458d8c4d59bdb1547e4630a2c6de4971946c4f0999443db6a9eef6d216b26b8"}, - {file = "prospector_profile_utils-1.9.1.tar.gz", hash = "sha256:008efa6797a85233fd8093dcb9d86f5fa5d89673e431c15cb1496a91c9b2c601"}, + {file = "prospector_profile_utils-1.14.0-py3-none-any.whl", hash = "sha256:15853e984314f90d688052c7dc09c9206779fdfb7f0606f6a4a617d167c6e693"}, + {file = "prospector_profile_utils-1.14.0.tar.gz", hash = "sha256:258bbe70c7411c7c11a7a7fc202c9a021db3d775a3bf45e7e8bd9f96206bcc48"}, ] +[package.dependencies] +prospector = ">=1.13.0" + [[package]] name = "psycopg2" version = "2.9.10" @@ -1724,6 +1728,33 @@ packaging = ">=21.3" semver = ">=3.0.0,<4.0.0" toml = {version = ">=0.10.2,<0.11.0", markers = "python_version < \"3.11\""} +[[package]] +name = "ruff" +version = "0.8.1" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.8.1-py3-none-linux_armv6l.whl", hash = "sha256:fae0805bd514066f20309f6742f6ee7904a773eb9e6c17c45d6b1600ca65c9b5"}, + {file = "ruff-0.8.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b8a4f7385c2285c30f34b200ca5511fcc865f17578383db154e098150ce0a087"}, + {file = "ruff-0.8.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:cd054486da0c53e41e0086e1730eb77d1f698154f910e0cd9e0d64274979a209"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2029b8c22da147c50ae577e621a5bfbc5d1fed75d86af53643d7a7aee1d23871"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2666520828dee7dfc7e47ee4ea0d928f40de72056d929a7c5292d95071d881d1"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:333c57013ef8c97a53892aa56042831c372e0bb1785ab7026187b7abd0135ad5"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:288326162804f34088ac007139488dcb43de590a5ccfec3166396530b58fb89d"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b12c39b9448632284561cbf4191aa1b005882acbc81900ffa9f9f471c8ff7e26"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:364e6674450cbac8e998f7b30639040c99d81dfb5bbc6dfad69bc7a8f916b3d1"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b22346f845fec132aa39cd29acb94451d030c10874408dbf776af3aaeb53284c"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b2f2f7a7e7648a2bfe6ead4e0a16745db956da0e3a231ad443d2a66a105c04fa"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:adf314fc458374c25c5c4a4a9270c3e8a6a807b1bec018cfa2813d6546215540"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a885d68342a231b5ba4d30b8c6e1b1ee3a65cf37e3d29b3c74069cdf1ee1e3c9"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d2c16e3508c8cc73e96aa5127d0df8913d2290098f776416a4b157657bee44c5"}, + {file = "ruff-0.8.1-py3-none-win32.whl", hash = "sha256:93335cd7c0eaedb44882d75a7acb7df4b77cd7cd0d2255c93b28791716e81790"}, + {file = "ruff-0.8.1-py3-none-win_amd64.whl", hash = "sha256:2954cdbe8dfd8ab359d4a30cd971b589d335a44d444b6ca2cb3d1da21b75e4b6"}, + {file = "ruff-0.8.1-py3-none-win_arm64.whl", hash = "sha256:55873cc1a473e5ac129d15eccb3c008c096b94809d693fc7053f588b67822737"}, + {file = "ruff-0.8.1.tar.gz", hash = "sha256:3583db9a6450364ed5ca3f3b4225958b24f78178908d5c4bc0f46251ccca898f"}, +] + [[package]] name = "scikit-image" version = "0.24.0" @@ -2424,4 +2455,4 @@ test = ["zope.testing"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.13" -content-hash = "0e07611b41ddb3e2f876e149801dba49e6d22284027d94eeead701d5f03bf021" +content-hash = "a50e08ab655cd7dd48a8fe9844f845ca02f4758fc1c6a18b2e965205fda33bf5" diff --git a/acceptance_tests/pyproject.toml b/acceptance_tests/pyproject.toml index 4d6d024f..c3e0cae0 100644 --- a/acceptance_tests/pyproject.toml +++ b/acceptance_tests/pyproject.toml @@ -7,9 +7,9 @@ authors = [] [tool.poetry.dependencies] python = ">=3.10,<3.13" pytest-cov = "6.0.0" -prospector = "1.12.1" -prospector-profile-duplicated = "1.6.0" -prospector-profile-utils = "1.9.1" +prospector = { version = "1.13.3", extras = ["with_ruff"] } +prospector-profile-duplicated = "1.8.1" +prospector-profile-utils = "1.14.0" typing-extensions = "4.12.2" c2cwsgiutils = { version = "6.1.5", extras = ["standard", "test_images"] } requests = "2.32.3" diff --git a/app/.bandit.yaml b/app/.bandit.yaml deleted file mode 100644 index 9df6fbfa..00000000 --- a/app/.bandit.yaml +++ /dev/null @@ -1,3 +0,0 @@ -skips: - - B101 # Use of assert detected. The enclosed code will be removed when compiling to optimized byte code. - - B113 # Call to requests without timeout, done globally by c2cwsgiutils diff --git a/app/.prospector.yaml b/app/.prospector.yaml index e87062b7..e85eafed 100644 --- a/app/.prospector.yaml +++ b/app/.prospector.yaml @@ -2,12 +2,21 @@ inherits: - utils:base - utils:no-design-checks - utils:fix + - utils:unsafe + - utils:c2cwsgiutils - duplicated -pylint: - disable: - - missing-timeout # Done by c2cwsgiutils +ignore-paths: + - shared_config_manager/configuration.py + - app/shared_config_manager/configuration.py +ignore-patterns: + - ^acceptance_tests/.*/test_.*\.py -bandit: +mypy: options: - config: .bandit.yaml + python_version: '3.10' + +ruff: + disable: + - D102 # Missing docstring in public method + - D107 # Missing docstring in `__init__` diff --git a/app/gunicorn.conf.py b/app/gunicorn.conf.py index a75eec9a..44db0d50 100644 --- a/app/gunicorn.conf.py +++ b/app/gunicorn.conf.py @@ -75,7 +75,6 @@ def on_starting(server: gunicorn.arbiter.Arbiter) -> None: Called just before the master process is initialized. """ - del server prometheus.start() @@ -87,7 +86,6 @@ def post_fork(server: gunicorn.arbiter.Arbiter, worker: gunicorn.workers.base.Wo Called just after a worker has been forked. """ - del server, worker prometheus.cleanup() @@ -99,7 +97,6 @@ def child_exit(server: gunicorn.arbiter.Arbiter, worker: gunicorn.workers.base.W Called just after a worker has been exited, in the master process. """ - del server multiprocess.mark_process_dead(worker.pid) # type: ignore [no-untyped-call] diff --git a/app/poetry.lock b/app/poetry.lock index 52952334..31718401 100644 --- a/app/poetry.lock +++ b/app/poetry.lock @@ -988,19 +988,18 @@ twisted = ["twisted"] [[package]] name = "prospector" -version = "1.12.1" +version = "1.13.3" description = "Prospector is a tool to analyse Python code by aggregating the result of other tools." optional = false python-versions = "<4.0,>=3.9" files = [ - {file = "prospector-1.12.1-py3-none-any.whl", hash = "sha256:e2440b51f40626cbaea80edd97263d8c0a71a79e729415fb505096d4d39e2287"}, - {file = "prospector-1.12.1.tar.gz", hash = "sha256:b9bb4bcdd77b943c597ee4f374960e851cdd2a0b4b60eaeeaf0da465facafc60"}, + {file = "prospector-1.13.3-py3-none-any.whl", hash = "sha256:e7261c222ba54bc8aef8c9e31b2dcf5ed2a656c9b76fc0cceab294cd5ec3db6b"}, + {file = "prospector-1.13.3.tar.gz", hash = "sha256:36ccb13f69aa27c5c4682afd4cc46219b9e0c80723e30dc64ff30c71f7b877a1"}, ] [package.dependencies] bandit = {version = ">=1.5.1", optional = true, markers = "extra == \"with-bandit\" or extra == \"with_everything\""} dodgy = ">=0.2.1,<0.3.0" -flake8 = "*" GitPython = ">=3.1.27,<4.0.0" mccabe = ">=0.7.0,<0.8.0" mypy = {version = ">=0.600", optional = true, markers = "extra == \"with-mypy\" or extra == \"with_everything\""} @@ -1015,40 +1014,45 @@ pylint-django = ">=2.6.1" pylint-flask = "0.6" pyroma = {version = ">=2.4", optional = true, markers = "extra == \"with-pyroma\" or extra == \"with_everything\""} PyYAML = "*" -requirements-detector = ">=1.3.1" +requirements-detector = ">=1.3.2" +ruff = {version = "*", optional = true, markers = "extra == \"with-ruff\" or extra == \"with_everything\""} setoptconf-tmp = ">=0.3.1,<0.4.0" toml = ">=0.10.2,<0.11.0" [package.extras] with-bandit = ["bandit (>=1.5.1)"] -with-everything = ["bandit (>=1.5.1)", "mypy (>=0.600)", "pyright (>=1.1.3)", "pyroma (>=2.4)", "vulture (>=1.5)"] +with-everything = ["bandit (>=1.5.1)", "mypy (>=0.600)", "pyright (>=1.1.3)", "pyroma (>=2.4)", "ruff", "vulture (>=1.5)"] with-mypy = ["mypy (>=0.600)"] with-pyright = ["pyright (>=1.1.3)"] with-pyroma = ["pyroma (>=2.4)"] +with-ruff = ["ruff"] with-vulture = ["vulture (>=1.5)"] [[package]] name = "prospector-profile-duplicated" -version = "1.6.0" +version = "1.8.1" description = "Profile that can be used to disable the duplicated or conflict rules between Prospector and other tools" optional = false python-versions = "*" files = [ - {file = "prospector_profile_duplicated-1.6.0-py2.py3-none-any.whl", hash = "sha256:bf6a6aae0c7de48043b95e4d42e23ccd090c6c7115b6ee8c8ca472ffb1a2022b"}, - {file = "prospector_profile_duplicated-1.6.0.tar.gz", hash = "sha256:9c2d541076537405e8b2484cb6222276a2df17492391b6af1b192695770aab83"}, + {file = "prospector_profile_duplicated-1.8.1-py2.py3-none-any.whl", hash = "sha256:a3c23517b9749ea0e61cc9b23d1526752c1eeb6c899cd0d9ec1fa77b1f373a49"}, + {file = "prospector_profile_duplicated-1.8.1.tar.gz", hash = "sha256:a08fa1f5aa77bdbc908b0c4f66b2bdb306aba10c44c5db51e389cd5cf79bda04"}, ] [[package]] name = "prospector-profile-utils" -version = "1.9.1" +version = "1.13.0" description = "Some utility Prospector profiles." optional = false -python-versions = "*" +python-versions = "<4.0,>=3.9" files = [ - {file = "prospector_profile_utils-1.9.1-py2.py3-none-any.whl", hash = "sha256:b458d8c4d59bdb1547e4630a2c6de4971946c4f0999443db6a9eef6d216b26b8"}, - {file = "prospector_profile_utils-1.9.1.tar.gz", hash = "sha256:008efa6797a85233fd8093dcb9d86f5fa5d89673e431c15cb1496a91c9b2c601"}, + {file = "prospector_profile_utils-1.13.0-py3-none-any.whl", hash = "sha256:f991f8f2709c5a2c693d0e0a672a8f3ce2db3f1767b4dc2fbe167395c7dbdbb3"}, + {file = "prospector_profile_utils-1.13.0.tar.gz", hash = "sha256:2f98ddda31c0fa024134fe687e9828855f3597ea52de7a710d1aa508de8fda0a"}, ] +[package.dependencies] +prospector = ">=1.13.0" + [[package]] name = "psycopg2" version = "2.9.10" @@ -1501,6 +1505,33 @@ typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.1 [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] +[[package]] +name = "ruff" +version = "0.8.1" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.8.1-py3-none-linux_armv6l.whl", hash = "sha256:fae0805bd514066f20309f6742f6ee7904a773eb9e6c17c45d6b1600ca65c9b5"}, + {file = "ruff-0.8.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b8a4f7385c2285c30f34b200ca5511fcc865f17578383db154e098150ce0a087"}, + {file = "ruff-0.8.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:cd054486da0c53e41e0086e1730eb77d1f698154f910e0cd9e0d64274979a209"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2029b8c22da147c50ae577e621a5bfbc5d1fed75d86af53643d7a7aee1d23871"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2666520828dee7dfc7e47ee4ea0d928f40de72056d929a7c5292d95071d881d1"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:333c57013ef8c97a53892aa56042831c372e0bb1785ab7026187b7abd0135ad5"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:288326162804f34088ac007139488dcb43de590a5ccfec3166396530b58fb89d"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b12c39b9448632284561cbf4191aa1b005882acbc81900ffa9f9f471c8ff7e26"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:364e6674450cbac8e998f7b30639040c99d81dfb5bbc6dfad69bc7a8f916b3d1"}, + {file = "ruff-0.8.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b22346f845fec132aa39cd29acb94451d030c10874408dbf776af3aaeb53284c"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b2f2f7a7e7648a2bfe6ead4e0a16745db956da0e3a231ad443d2a66a105c04fa"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:adf314fc458374c25c5c4a4a9270c3e8a6a807b1bec018cfa2813d6546215540"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a885d68342a231b5ba4d30b8c6e1b1ee3a65cf37e3d29b3c74069cdf1ee1e3c9"}, + {file = "ruff-0.8.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d2c16e3508c8cc73e96aa5127d0df8913d2290098f776416a4b157657bee44c5"}, + {file = "ruff-0.8.1-py3-none-win32.whl", hash = "sha256:93335cd7c0eaedb44882d75a7acb7df4b77cd7cd0d2255c93b28791716e81790"}, + {file = "ruff-0.8.1-py3-none-win_amd64.whl", hash = "sha256:2954cdbe8dfd8ab359d4a30cd971b589d335a44d444b6ca2cb3d1da21b75e4b6"}, + {file = "ruff-0.8.1-py3-none-win_arm64.whl", hash = "sha256:55873cc1a473e5ac129d15eccb3c008c096b94809d693fc7053f588b67822737"}, + {file = "ruff-0.8.1.tar.gz", hash = "sha256:3583db9a6450364ed5ca3f3b4225958b24f78178908d5c4bc0f46251ccca898f"}, +] + [[package]] name = "semver" version = "3.0.2" @@ -2150,4 +2181,4 @@ test = ["zope.testing"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.13" -content-hash = "aa4ab726ee2499438a8203574ff1a616cdfd6d99297ef194d5d601c8ccb0ba52" +content-hash = "ea87fee75e7ec84d529fd9ab046dadebab5fe7ad437d07ca07ebb2f6979b1c5a" diff --git a/app/pyproject.toml b/app/pyproject.toml index dea1da18..2847b072 100644 --- a/app/pyproject.toml +++ b/app/pyproject.toml @@ -20,9 +20,9 @@ c2cwsgiutils = { version = "6.1.5", extras = ["broadcast", "standard", "oauth2", pyramid-mako = "1.1.0" [tool.poetry.dev-dependencies] -prospector = { extras = ["with_mypy", "with_bandit", "with_pyroma"], version = "1.12.1" } -prospector-profile-duplicated = "1.6.0" -prospector-profile-utils = "1.9.1" +prospector = { version = "1.13.3", extras = ["with_mypy", "with_bandit", "with_pyroma", "with_ruff"] } +prospector-profile-duplicated = "1.8.1" +prospector-profile-utils = "1.13.0" types-pyyaml = "6.0.12.20240917" types-requests = "2.32.0.20241016" pytest = "8.3.4" diff --git a/app/shared_config_manager/app.py b/app/shared_config_manager/app.py index 3d9b1087..d5e71f31 100644 --- a/app/shared_config_manager/app.py +++ b/app/shared_config_manager/app.py @@ -13,6 +13,7 @@ def forbidden(request: pyramid.request.Request) -> pyramid.response.Response: + """Redirect to the login page if the user is not authenticated.""" is_auth = c2cwsgiutils.auth.is_auth(request) if is_auth: @@ -26,6 +27,7 @@ def forbidden(request: pyramid.request.Request) -> pyramid.response.Response: def main(_: Any, **settings: Any) -> Any: + """Get the WSGI application.""" config = Configurator(settings=settings, route_prefix=os.environ.get("ROUTE_PREFIX", "/scm")) config.include(c2cwsgiutils.pyramid.includeme) diff --git a/app/shared_config_manager/scripts/shared_config_slave.py b/app/shared_config_manager/scripts/shared_config_slave.py index a4905450..7aeac61e 100755 --- a/app/shared_config_manager/scripts/shared_config_slave.py +++ b/app/shared_config_manager/scripts/shared_config_slave.py @@ -9,12 +9,11 @@ import c2cwsgiutils.setup_process import prometheus_client - -from shared_config_manager import slave_status # noqa: F401, pylint: disable=unused-import from shared_config_manager.sources import registry def main() -> None: + """Get the WSGI application.""" parser = argparse.ArgumentParser(description="Run the shared config slave") c2cwsgiutils.setup_process.fill_arguments(parser) args = parser.parse_args() diff --git a/app/shared_config_manager/security.py b/app/shared_config_manager/security.py index 10cd8f34..1dc3c860 100644 --- a/app/shared_config_manager/security.py +++ b/app/shared_config_manager/security.py @@ -13,6 +13,8 @@ class User: + """User object for the application.""" + auth_type: str login: str | None name: str | None @@ -53,9 +55,10 @@ def has_access(self, source_config: SourceConfig) -> bool: class SecurityPolicy: + """Security policy for the application.""" + def identity(self, request: pyramid.request.Request) -> User: """Return app-specific user object.""" - if not hasattr(request, "user"): user = None @@ -114,13 +117,12 @@ def identity(self, request: pyramid.request.Request) -> User: request, ) - setattr(request, "user", user) + request.user = user return request.user # type: ignore def authenticated_userid(self, request: pyramid.request.Request) -> str | None: """Return a string ID for the user.""" - identity = self.identity(request) if identity is None: @@ -132,7 +134,6 @@ def permits( self, request: pyramid.request.Request, context: SourceConfig, permission: str ) -> Allowed | Denied: """Allow access to everything if signed in.""" - identity = self.identity(request) if identity is None: diff --git a/app/shared_config_manager/services.py b/app/shared_config_manager/services.py index 5e6125fa..af116ad5 100644 --- a/app/shared_config_manager/services.py +++ b/app/shared_config_manager/services.py @@ -76,7 +76,7 @@ def _refresh_all(request: pyramid.request.Request) -> dict[str, Any]: raise HTTPServerError("Master source not initialized") registry.MASTER_SOURCE.validate_auth(request) nb_refresh = 0 - for id_ in registry.get_sources().keys(): + for id_ in registry.get_sources(): registry.refresh(id_=id_, request=request) nb_refresh += 1 return {"status": 200, "nb_refresh": nb_refresh} diff --git a/app/shared_config_manager/slave_status.py b/app/shared_config_manager/slave_status.py index 247d6916..db34e792 100644 --- a/app/shared_config_manager/slave_status.py +++ b/app/shared_config_manager/slave_status.py @@ -6,11 +6,13 @@ @broadcast.decorator(expect_answers=True) def get_slaves_status() -> SlaveStatus: + """Get the status of all the slaves.""" return {"sources": registry.get_stats()} @broadcast.decorator(expect_answers=True) def get_source_status(id_: str) -> SourceStatus: + """Get the status of a source.""" source = registry.get_source(id_) if source is None: return {"filtered": id_ in registry.FILTERED_SOURCES} diff --git a/app/shared_config_manager/sources/base.py b/app/shared_config_manager/sources/base.py index 1831437b..cbe1e26c 100644 --- a/app/shared_config_manager/sources/base.py +++ b/app/shared_config_manager/sources/base.py @@ -46,6 +46,8 @@ class BaseSource: + """Base class for sources.""" + def __init__(self, id_: str, config: SourceConfig, is_master: bool) -> None: self._id = id_ self._config = config @@ -207,7 +209,7 @@ def get_stats(self) -> SourceStatus: config_copy = copy.deepcopy(self._config) stats_ = cast(SourceStatus, config_copy) for template_stats, template_engine in zip( - stats_.get("template_engines", []), self._template_engines + stats_.get("template_engines", []), self._template_engines, strict=False ): template_engine.get_stats(template_stats) @@ -264,12 +266,10 @@ def _hide_sensitive(data: dict[str, str] | None) -> None: @broadcast.decorator(expect_answers=False) def _set_refresh_success(source: str) -> None: """Set refresh in success in all process.""" - _REFRESH_ERROR_GAUGE.labels(source=source).set(0) @broadcast.decorator(expect_answers=False) def _set_fetch_success(source: str) -> None: """Set fetch in success in all process.""" - _FETCH_ERROR_GAUGE.labels(source=source).set(0) diff --git a/app/shared_config_manager/sources/git.py b/app/shared_config_manager/sources/git.py index fce97f2a..325fa878 100644 --- a/app/shared_config_manager/sources/git.py +++ b/app/shared_config_manager/sources/git.py @@ -13,6 +13,8 @@ class GitSource(SshBaseSource): + """Source that get files with git.""" + def _do_refresh(self) -> None: self._checkout() self._copy(self._copy_dir(), excludes=[".git"]) diff --git a/app/shared_config_manager/sources/mode.py b/app/shared_config_manager/sources/mode.py index 73f68b50..ccbf8ab9 100644 --- a/app/shared_config_manager/sources/mode.py +++ b/app/shared_config_manager/sources/mode.py @@ -4,6 +4,7 @@ def init(slave: bool) -> None: + """Initialize the mode.""" global API_BASE_URL # pylint: disable=global-statement if slave: API_BASE_URL = os.environ["API_BASE_URL"] @@ -12,12 +13,15 @@ def init(slave: bool) -> None: def is_master() -> bool: + """Is the master.""" return API_BASE_URL is None def is_master_with_slaves() -> bool: + """Is the master with slaves.""" return is_master() and os.environ.get("API_MASTER") is not None def get_fetch_url(id_: str) -> str: + """Get the URL to fetch the tarball.""" return f"{API_BASE_URL}1/tarball/{id_}" diff --git a/app/shared_config_manager/sources/rclone.py b/app/shared_config_manager/sources/rclone.py index 3ec82046..760e334a 100644 --- a/app/shared_config_manager/sources/rclone.py +++ b/app/shared_config_manager/sources/rclone.py @@ -6,6 +6,8 @@ class RcloneSource(BaseSource): + """Source that get files with rclone.""" + def __init__(self, id_: str, config: SourceConfig, is_master: bool): super().__init__(id_, config, is_master) self._setup_config(config["config"]) diff --git a/app/shared_config_manager/sources/registry.py b/app/shared_config_manager/sources/registry.py index eb736951..42bb6fde 100644 --- a/app/shared_config_manager/sources/registry.py +++ b/app/shared_config_manager/sources/registry.py @@ -30,12 +30,14 @@ def _create_source(id_: str, config: SourceConfig, is_master: bool = False) -> b def get_sources() -> Mapping[str, base.BaseSource]: + """Get all the sources.""" copy = dict(_SOURCES.items()) copy.update(FILTERED_SOURCES) return copy def init(slave: bool) -> None: + """Initialize the registry.""" global MASTER_SOURCE # pylint: disable=global-statement mode.init(slave) if slave: @@ -82,6 +84,7 @@ def thread() -> None: def reload_master_config() -> None: + """Reload the master config.""" if MASTER_SOURCE: with open( os.path.join(MASTER_SOURCE.get_path(), "shared_config_manager.yaml"), encoding="utf-8" @@ -166,7 +169,7 @@ def _delete_source(id_: str) -> None: def _filter_sources( - source_configs: dict[str, SourceConfig] + source_configs: dict[str, SourceConfig], ) -> tuple[dict[str, SourceConfig], dict[str, SourceConfig]]: if _TAG_FILTER is None or mode.is_master(): return source_configs, {} @@ -182,6 +185,8 @@ def _filter_sources( def refresh(id_: str, request: pyramid.request.Request | None) -> None: """ + Do a refresh. + This is called from the web service to start a refresh. """ _LOG.info("Reloading the %s config", id_) @@ -195,9 +200,7 @@ def refresh(id_: str, request: pyramid.request.Request | None) -> None: def _slave_fetch(id_: str) -> None: - """ - This is run on every slave when a source needs a refresh. - """ + """Do a refresh on the slave.""" source, filtered = get_source_check_auth(id_, None) if source is None: _LOG.error("Unknown id %d", id_) @@ -215,6 +218,7 @@ def _slave_fetch(id_: str) -> None: def get_source_check_auth( id_: str, request: pyramid.request.Request | None ) -> tuple[base.BaseSource | None, bool]: + """Get a source by id and check the auth.""" filtered = False source = get_source(id_) if source is None: @@ -228,6 +232,7 @@ def get_source_check_auth( def get_source(id_: str) -> base.BaseSource | None: + """Get a source by id.""" if MASTER_SOURCE and MASTER_SOURCE.get_id() == id_: return MASTER_SOURCE else: @@ -235,6 +240,7 @@ def get_source(id_: str) -> base.BaseSource | None: def get_stats() -> dict[str, SourceStatus]: + """Get the stats of all the sources.""" return ( { id_: source.get_stats() diff --git a/app/shared_config_manager/sources/rsync.py b/app/shared_config_manager/sources/rsync.py index 2d41ccf2..001ee5df 100644 --- a/app/shared_config_manager/sources/rsync.py +++ b/app/shared_config_manager/sources/rsync.py @@ -2,5 +2,7 @@ class RsyncSource(SshBaseSource): + """Source that get files with rsync.""" + def _do_refresh(self) -> None: self._copy(self._config["source"]) diff --git a/app/shared_config_manager/sources/ssh.py b/app/shared_config_manager/sources/ssh.py index f4bb5415..0e507f47 100644 --- a/app/shared_config_manager/sources/ssh.py +++ b/app/shared_config_manager/sources/ssh.py @@ -20,6 +20,8 @@ def _patch_openshift() -> None: class SshBaseSource(BaseSource): + """Source to get files from SSH server.""" + def __init__(self, id_: str, config: SourceConfig, is_master: bool) -> None: super().__init__(id_, config, is_master) self._setup_key(config.get("ssh_key")) diff --git a/app/shared_config_manager/template_engines/__init__.py b/app/shared_config_manager/template_engines/__init__.py index ce9b46e1..f7349bf1 100644 --- a/app/shared_config_manager/template_engines/__init__.py +++ b/app/shared_config_manager/template_engines/__init__.py @@ -5,5 +5,6 @@ def create_engine(source_id: str, config: TemplateEnginesConfig) -> base.BaseEngine: + """Create a template engine.""" type_ = config["type"] return ENGINES[type_](source_id, config) diff --git a/app/shared_config_manager/template_engines/base.py b/app/shared_config_manager/template_engines/base.py index 6b4a299a..87547695 100644 --- a/app/shared_config_manager/template_engines/base.py +++ b/app/shared_config_manager/template_engines/base.py @@ -4,7 +4,10 @@ from prometheus_client import Counter, Gauge -from shared_config_manager.configuration import TemplateEnginesConfig, TemplateEnginesStatus +from shared_config_manager.configuration import ( + TemplateEnginesConfig, + TemplateEnginesStatus, +) _LOG = logging.getLogger(__name__) _ENV_PREFIXES = os.environ.get("SCM_ENV_PREFIXES", "MUTUALIZED_").split(":") @@ -15,6 +18,8 @@ class BaseEngine: + """Base class for template engines.""" + def __init__(self, source_id: str, config: TemplateEnginesConfig, extension: str) -> None: self._source_id = source_id self._config = config diff --git a/app/shared_config_manager/template_engines/mako.py b/app/shared_config_manager/template_engines/mako.py index f9cd73de..b8eeef76 100644 --- a/app/shared_config_manager/template_engines/mako.py +++ b/app/shared_config_manager/template_engines/mako.py @@ -5,10 +5,12 @@ class MakoEngine(BaseEngine): + """Mako template engine.""" + def __init__(self, source_id: str, config: TemplateEnginesConfig) -> None: super().__init__(source_id, config, "mako") def _evaluate_file(self, src_path: str, dst_path: str) -> None: - template = mako.template.Template(filename=src_path) # nosec + template = mako.template.Template(filename=src_path) # nosec # noqa: S702 with open(dst_path, "w", encoding="utf-8") as output: output.write(template.render(**self._data)) diff --git a/app/shared_config_manager/template_engines/shell.py b/app/shared_config_manager/template_engines/shell.py index 157ca53d..e996c380 100644 --- a/app/shared_config_manager/template_engines/shell.py +++ b/app/shared_config_manager/template_engines/shell.py @@ -5,6 +5,8 @@ class ShellEngine(BaseEngine): + """Shell template engine (envsubst).""" + def __init__(self, source_id: str, config: TemplateEnginesConfig) -> None: super().__init__(source_id, config, "tmpl") diff --git a/pyproject.toml b/pyproject.toml index 36a48c12..099756b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,5 @@ -[tool.black] -line-length = 110 -target-version = ["py310"] - -[tool.isort] -profile = "black" -line_length = 110 -known_first_party = "shared_config_manager" +[tool.ruff] +target-version = "py310" [tool.poetry] name = "shared-config-manager"