From 95b87601b02b9a2da987c2746f417a7d9646bedc Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:25:15 +0200 Subject: [PATCH] ci/lint: update & simplify & bump `py3.8` (#48) * ci/lint: update & simplify * min py3.8 * pyproject fixed --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/ci_testing.yml | 2 +- .pre-commit-config.yaml | 40 ++++----- .prettierignore | 2 - pyproject.toml | 141 ++++++++++++++----------------- setup.py | 4 +- 5 files changed, 83 insertions(+), 106 deletions(-) delete mode 100644 .prettierignore diff --git a/.github/workflows/ci_testing.yml b/.github/workflows/ci_testing.yml index 6f62a51..75b2ecc 100644 --- a/.github/workflows/ci_testing.yml +++ b/.github/workflows/ci_testing.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - python-version: ["3.7", "3.11"] + python-version: ["3.8", "3.11"] # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 10 steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 767aeda..c852351 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,17 +22,11 @@ repos: - id: check-docstring-first - id: detect-private-key - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 - hooks: - - id: pyupgrade - args: ["--py37-plus"] - name: Upgrade code - - repo: https://github.com/pre-commit/mirrors-prettier rev: v3.1.0 hooks: - id: prettier + files: \.(html|yml|yaml|toml) # https://prettier.io/docs/en/options.html#print-width args: ["--print-width=120"] @@ -50,12 +44,6 @@ repos: additional_dependencies: [tomli] args: [--in-place] - - repo: https://github.com/psf/black - rev: 24.3.0 - hooks: - - id: black - name: Format code - #- repo: https://github.com/pre-commit/mirrors-mypy # rev: v0.991 # hooks: @@ -71,17 +59,23 @@ repos: - mdformat-black - mdformat_frontmatter - - repo: https://github.com/asottile/yesqa - rev: v1.5.0 - hooks: - - id: yesqa - additional_dependencies: - - pep8-naming - - flake8-pytest-style - - flake8-bandit - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.4 + rev: v0.3.5 hooks: + # try to fix what is possible - id: ruff args: ["--fix"] + # perform formatting updates + - id: ruff-format + # validate if all is fine with preview mode + - id: ruff + + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 1.7.0 + hooks: + - id: pyproject-fmt + additional_dependencies: [tox] + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.16 + hooks: + - id: validate-pyproject diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index c5646f7..0000000 --- a/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore all MD files: -**/*.md diff --git a/pyproject.toml b/pyproject.toml index 407f75a..d8921b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,77 +1,23 @@ -[metadata] -license_file = "LICENSE" -description-file = "README.md" - [build-system] requires = [ - "setuptools", - "wheel", -] - - -[tool.check-manifest] -ignore = [ - "*.yml", - ".github", - ".github/*" -] - - -[tool.pytest.ini_options] -norecursedirs = [ - ".git", - ".github", - "dist", - "build", - "docs", + "setuptools", + "wheel", ] -addopts = [ - "--strict-markers", - "--doctest-modules", - "--color=yes", - "--disable-pytest-warnings", -] -#filterwarnings = ["error::FutureWarning"] -xfail_strict = true -junit_duration_report = "call" - -[tool.coverage.report] -exclude_lines = [ - "pragma: no cover", - "pass", -] -[tool.coverage.run] -parallel = true -relative_files = true - - -[tool.codespell] -#skip = '*.py' -quiet-level = 3 -# comma separated list of words; waiting for: -# https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603 -# also adding links until they ignored by its: nature -# https://github.com/codespell-project/codespell/issues/2243#issuecomment-1732019960 -#ignore-words-list = "" - - -[tool.docformatter] -recursive = true -# this need to be shorter as some docstings are r"""... -wrap-summaries = 119 -wrap-descriptions = 120 -blank = true - [tool.black] # https://github.com/psf/black line-length = 120 exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)" - [tool.ruff] +target-version = "py38" line-length = 120 -# Enable Pyflakes `E` and `F` codes by default. +# Exclude a variety of commonly ignored directories. +exclude = [ + "docs" +] + +[tool.ruff.lint] select = [ "E", "W", # see: https://pypi.org/project/pycodestyle "F", # see: https://pypi.org/project/pyflakes @@ -79,6 +25,8 @@ select = [ "D", # see: https://pypi.org/project/pydocstyle "N", # see: https://pypi.org/project/pep8-naming "S", # see: https://pypi.org/project/flake8-bandit + "RUF018", # see: https://docs.astral.sh/ruff/rules/assignment-in-assert + "UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up ] extend-select = [ "C4", # see: https://pypi.org/project/flake8-comprehensions @@ -88,35 +36,72 @@ extend-select = [ "YTT", # see: https://pypi.org/project/flake8-2020 "ANN", # see: https://pypi.org/project/flake8-annotations ] -# Exclude a variety of commonly ignored directories. -exclude = [ - ".eggs", - ".git", - ".mypy_cache", - ".ruff_cache", - "__pypackages__", - "_build", - "build", - "dist", - "docs" -] ignore-init-module-imports = true unfixable = ["F401"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "setup.py" = ["ANN202", "ANN401"] "src/**" = ["ANN401"] "tests/**" = [ "D100", "D101", "D103", "D107", "S101", "ANN101", "ANN401" ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] # Use Google-style docstrings. convention = "google" -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] # Unlike Flake8, default to a complexity level of 10. max-complexity = 10 +[tool.codespell] +#skip = '*.py' +quiet-level = 3 +# comma separated list of words; waiting for: +# https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603 +# also adding links until they ignored by its: nature +# https://github.com/codespell-project/codespell/issues/2243#issuecomment-1732019960 +#ignore-words-list = "" + +[tool.docformatter] +recursive = true +# this need to be shorter as some docstings are r"""... +wrap-summaries = 119 +wrap-descriptions = 120 +blank = true + +[tool.check-manifest] +ignore = [ + "*.yml", + ".github", + ".github/*" +] + +[tool.pytest.ini_options] +norecursedirs = [ + ".git", + ".github", + "dist", + "build", + "docs", +] +addopts = [ + "--strict-markers", + "--doctest-modules", + "--color=yes", + "--disable-pytest-warnings", +] +#filterwarnings = ["error::FutureWarning"] +xfail_strict = true +junit_duration_report = "call" + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "pass", +] +[tool.coverage.run] +parallel = true +relative_files = true [tool.mypy] files = ["deprecate"] diff --git a/setup.py b/setup.py index e298999..d4eaef8 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Copyright (C) 2020-2023 Jiri Borovec <...>.""" + import os from importlib.util import module_from_spec, spec_from_file_location @@ -50,7 +51,7 @@ def _load_long_description(path_dir: str, version: str) -> str: include_package_data=True, zip_safe=False, keywords=["python", "development", "deprecation"], - python_requires=">=3.6", + python_requires=">=3.8", setup_requires=[], install_requires=[], project_urls={"Source Code": ABOUT.__source_code__, "Home page": ABOUT.__homepage__}, @@ -68,7 +69,6 @@ def _load_long_description(path_dir: str, version: str) -> str: # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10",