From 1a293563d110f2d5fa718c3b3e4ad74215b9e2a2 Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Mon, 16 Oct 2023 17:34:07 +0200 Subject: [PATCH] Upgrade dev dependencies; upgrade to newer reusable Github workflow; rename requirements files; add `ruff` linting rules; add `black` config for line length 80 --- .github/workflows/ci.yaml | 6 +-- pyproject.toml | 58 +++++++++++++++++++-------- requirements/{common.txt => base.txt} | 0 requirements/dev.txt | 16 ++++---- requirements/full.txt | 1 + 5 files changed, 53 insertions(+), 28 deletions(-) rename requirements/{common.txt => base.txt} (100%) create mode 100644 requirements/full.txt diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3a047c5..5140298 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,9 +8,9 @@ on: jobs: test: name: Test - uses: daniil-berg/reusable-workflows/.github/workflows/python-test.yaml@v0.2.1 + uses: daniil-berg/reusable-workflows/.github/workflows/python-test.yaml@v0.2.2 with: - versions: '["3.9", "3.10", "3.11"]' + versions: '["3.9", "3.10", "3.11", "3.12"]' unittest-command: 'scripts/test.sh' coverage-command: 'scripts/cov.sh' unittest-requirements: "-e '.[dev]'" @@ -24,7 +24,7 @@ jobs: name: Release if: ${{ github.ref_type == 'tag' }} needs: test - uses: daniil-berg/reusable-workflows/.github/workflows/python-release.yaml@v0.2.1 + uses: daniil-berg/reusable-workflows/.github/workflows/python-release.yaml@v0.2.2 with: git-ref: ${{ github.ref_name }} secrets: diff --git a/pyproject.toml b/pyproject.toml index 24bf73e..ed9b1d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,18 +39,16 @@ dynamic = [ ] [project.optional-dependencies] -full = [ - ... -] +full = [] dev = [ - "black==23.7.0", - "build==0.10.0", - "coverage[toml]==7.2.7", + "black==23.9.1", + "build==1.0.3", + "coverage[toml]==7.3.2", "isort==5.12.0", - "mkdocs-material==9.1.18", - "mkdocstrings[python]==0.22.0", - "mypy==1.4.1", - "ruff==0.0.278", + "mkdocs-material==9.4.6", + "mkdocstrings[python]==0.23.0", + "mypy==1.5.1", + "ruff==0.0.292", ] [project.urls] @@ -109,25 +107,44 @@ omit = [ [tool.ruff] cache-dir = ".cache/ruff" select = [ + "F", # pyflakes "E", # pycodestyle errors "W", # pycodestyle warnings - "F", # pyflakes + "N", # pep8-naming "D", # pydocstyle - "C", # flake8-comprehensions + "ANN", # flake8-annotations + "S", # flake8-bandit + "FBT", # flake8-boolean-trap "B", # flake8-bugbear + "A", # flake8-builtins + "C", # flake8-comprehensions + "PIE", # flake8-pie + "T20", # flake8-print + "RET", # flake8-return + "SIM", # flake8-simplify + "TD", # flake8-todos + "TCH", # flake8-type-checking + "ARG", # flake8-unused-arguments + "PTH", # flake8-use-pathlib + "ERA", # eradicate "PL", # pylint + "TRY", # tryceratops "RUF", # ruff-specific ] ignore = [ - "E501", # Line too long -> handled by black - "D203", # 1 blank line required before class docstring -> D211 is better - "D212", # Multi-line docstring summary should start at the first line -> ugly, D212 is better - "D401", # First line of docstring should be in imperative mood -> no, it shouldn't - "D407", # Missing dashed underline after section -> different docstring style + "E501", # Line too long -> handled by black + "D203", # 1 blank line required before class docstring -> D211 is better + "D212", # Multi-line docstring summary should start at the first line -> ugly, D213 is better + "D401", # First line of docstring should be in imperative mood -> no, it shouldn't + "D407", # Missing dashed underline after section -> different docstring style + "ANN101", # Missing type annotation for self in method -> unnecessary + "ANN102", # Missing type annotation for cls in classmethod -> unnecessary + "ANN401", # Dynamically typed expressions (typing.Any) are disallowed -> we'll use it sparingly ] [tool.ruff.per-file-ignores] "src/**/__init__.py" = [ + "A001", # Variable {name} is shadowing a Python builtin "D104", # Missing docstring in public package "F401", # {...} imported but unused ] @@ -138,9 +155,16 @@ ignore = [ "D104", # Missing docstring in public package ] +#################### +# Code formatting: # + +[tool.black] +line_length = 80 + ################### # Import sorting: # [tool.isort] profile = "black" extra_standard_library = ["typing_extensions"] +line_length = 80 diff --git a/requirements/common.txt b/requirements/base.txt similarity index 100% rename from requirements/common.txt rename to requirements/base.txt diff --git a/requirements/dev.txt b/requirements/dev.txt index 30ae0be..503774c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,9 +1,9 @@ --r common.txt -black==23.7.0 -build==0.10.0 -coverage[toml]==7.2.7 +-r full.txt +black==23.9.1 +build==1.0.3 +coverage[toml]==7.3.2 isort==5.12.0 -mkdocs-material==9.1.18 -mkdocstrings[python]==0.22.0 -mypy==1.4.1 -ruff==0.0.278 +mkdocs-material==9.4.6 +mkdocstrings[python]==0.23.0 +mypy==1.5.1 +ruff==0.0.292 diff --git a/requirements/full.txt b/requirements/full.txt new file mode 100644 index 0000000..9c9dec9 --- /dev/null +++ b/requirements/full.txt @@ -0,0 +1 @@ +-r base.txt \ No newline at end of file