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

Chore: Update DevOps tooling from central repository [skip ci] #19

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 4 additions & 41 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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)^(
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down
28 changes: 28 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 14 additions & 2 deletions src/osc_physrisk_financial/skeleton.py
Original file line number Diff line number Diff line change
@@ -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``::

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down