From 1a65fa87dffad3a344e758ffd67ae21f204a1b40 Mon Sep 17 00:00:00 2001 From: ModeSevenIndustrialSolutions <93649628+ModeSevenIndustrialSolutions@users.noreply.github.com> Date: Mon, 15 Jul 2024 08:18:20 +0000 Subject: [PATCH 1/2] Chore: Update DevOps tooling from central repository [skip ci] Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/bootstrap.yaml | 4 +-- .pre-commit-config.yaml | 45 +++----------------------------- ruff.toml | 28 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 43 deletions(-) create mode 100644 ruff.toml diff --git a/.github/workflows/bootstrap.yaml b/.github/workflows/bootstrap.yaml index 3e1df48..4886b3b 100644 --- a/.github/workflows/bootstrap.yaml +++ b/.github/workflows/bootstrap.yaml @@ -212,8 +212,8 @@ jobs: git branch -D "$AUTOMATION_BRANCH" || : git checkout -b "$AUTOMATION_BRANCH" else - # The -B flag swaps branch and creates it if NOT present - git checkout -B "$AUTOMATION_BRANCH" + git fetch origin "$AUTOMATION_BRANCH" + git switch -c "$AUTOMATION_BRANCH" "origin/$AUTOMATION_BRANCH" fi # Only if NOT running in GitHub diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8269e08..e4c8597 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,6 @@ --- ci: autofix_commit_msg: "Chore: pre-commit autoupdate" - skip: - # pre-commit.ci cannot install WGET, so tomlint must be disabled - - tomllint exclude: | (?x)^( @@ -13,21 +10,10 @@ exclude: | repos: - - repo: local - hooks: - - id: tomllint - name: "Script: scripts/tomllint.sh" - language: script - # pass_filenames: false - files: \^*.toml - types: [file] - entry: scripts/tomllint.sh . - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: - id: check-added-large-files - - id: check-ast - id: check-case-conflict - id: check-executables-have-shebangs - id: check-json @@ -38,17 +24,15 @@ repos: # - id: detect-aws-credentials - id: check-xml - id: check-yaml - - id: debug-statements - id: detect-private-key - id: end-of-file-fixer - - id: mixed-line-ending - args: ["--fix=lf"] + # - id: mixed-line-ending + # args: ["--fix=lf"] - id: name-tests-test args: ["--pytest-test-first"] - id: no-commit-to-branch # - id: pretty-format-json - id: requirements-txt-fixer - - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 @@ -78,25 +62,13 @@ repos: rev: v0.10.0.1 hooks: - id: shellcheck - - - repo: https://github.com/pycqa/pydocstyle.git - rev: 6.3.0 - hooks: - - id: pydocstyle - additional_dependencies: ["tomli"] + args: ["-x"] # Check external files - repo: https://github.com/Mateusz-Grzelinski/actionlint-py rev: v1.7.1.15 hooks: - id: actionlint - - repo: https://github.com/pycqa/flake8 - rev: "7.1.0" - hooks: - - id: flake8 - additional_dependencies: - - pep8-naming - - repo: https://github.com/adrienverge/yamllint.git rev: v1.35.1 hooks: @@ -107,10 +79,8 @@ repos: rev: v0.5.1 hooks: - id: ruff - files: ^(scripts|tests|custom_components)/.+\.py$ - args: [--fix, --exit-non-zero-on-fix] + args: [--fix, --exit-non-zero-on-fix, --config=ruff.toml] - id: ruff-format - files: ^(scripts|tests|custom_components)/.+\.py$ - repo: local hooks: @@ -134,13 +104,6 @@ repos: # hooks: # - id: codespell - # To embrace black styles, even in docs - # - repo: https://github.com/asottile/blacken-docs - # rev: v1.13.0 - # hooks: - # - id: blacken-docs - # additional_dependencies: [black] - # Automatically upgrade Python syntax for newer versions # - repo: https://github.com/asottile/pyupgrade # rev: v3.15.0 diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..4104517 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,28 @@ +[lint] +extend-fixable = [ + #Instead of trailing-whitespace + "W291", "W293" + ] + +extend-select = [ + # Instead of pydocstyle + "D", + #Instead of flake8 + "E", "F","B", + # Instead of pep8-naming + "N", + # Instead of flake8-debugger or debug-statements + "T10", +] + +ignore = [ + "E203", + "E501", + + # Avoid incompatible rules + "D203", + "D213", +] + +[lint.pycodestyle] +max-line-length = 160 From 1a0a223446387bbb5fbd7b320c1d1662dcb807fc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 08:18:33 +0000 Subject: [PATCH 2/2] Chore: pre-commit autoupdate --- src/osc_physrisk_financial/skeleton.py | 16 ++++++++++++++-- tests/conftest.py | 3 +-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/osc_physrisk_financial/skeleton.py b/src/osc_physrisk_financial/skeleton.py index 46239d8..7c171e1 100644 --- a/src/osc_physrisk_financial/skeleton.py +++ b/src/osc_physrisk_financial/skeleton.py @@ -1,5 +1,4 @@ -""" -This is a skeleton file that can serve as a starting point for a Python +"""This is a skeleton file that can serve as a starting point for a Python console script. To run this script uncomment the following lines in the ``[options.entry_points]`` section in ``setup.cfg``:: @@ -13,11 +12,14 @@ also be used as template for Python modules. Note: +---- This file can be renamed depending on your needs or safely removed if not needed. References: +---------- - https://setuptools.pypa.io/en/latest/userguide/entry_point.html - https://pip.pypa.io/en/stable/reference/pip_install + """ import argparse @@ -44,10 +46,13 @@ def fib(n): """Fibonacci example function Args: + ---- n (int): integer Returns: + ------- int: n-th Fibonacci number + """ assert n > 0 a, b = 1, 1 @@ -66,11 +71,14 @@ def parse_args(args): """Parse command line parameters Args: + ---- args (List[str]): command line parameters as list of strings (for example ``["--help"]``). Returns: + ------- :obj:`argparse.Namespace`: command line parameters namespace + """ parser = argparse.ArgumentParser(description="Just a Fibonacci demonstration") parser.add_argument( @@ -102,7 +110,9 @@ def setup_logging(loglevel): """Setup basic logging Args: + ---- loglevel (int): minimum loglevel for emitting messages + """ logformat = "[%(asctime)s] %(levelname)s:%(name)s:%(message)s" logging.basicConfig( @@ -117,8 +127,10 @@ def main(args): ``stdout`` in a nicely formatted message. Args: + ---- args (List[str]): command line parameters as list of strings (for example ``["--verbose", "42"]``). + """ args = parse_args(args) setup_logging(args.loglevel) diff --git a/tests/conftest.py b/tests/conftest.py index 067af0d..613ef19 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,4 @@ -""" -Dummy conftest.py for osc_physrisk_financial. +"""Dummy conftest.py for osc_physrisk_financial. If you don't know what this is for, just leave it empty. Read more about conftest.py under: