diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 2bcd70e3..00000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 88 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8dadafee..2216de2a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,33 +1,15 @@ repos: - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.0 hooks: - - id: pyupgrade - args: [--py38-plus] + - id: ruff + args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - additional_dependencies: - [flake8-2020, flake8-errmsg, flake8-implicit-str-concat] - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-check-blanket-noqa - - id: python-no-log-warn - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -36,19 +18,20 @@ repos: - id: check-json - id: check-toml - id: check-yaml + - id: debug-statements - id: end-of-file-fixer - id: requirements-txt-fixer - id: trailing-whitespace exclude: tests/data/expected_tabulated.py - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.5.3 + rev: 1.7.0 hooks: - id: pyproject-fmt additional_dependencies: [tox] - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject @@ -63,5 +46,10 @@ repos: - id: prettier args: [--prose-wrap=always, --print-width=88] + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + ci: autoupdate_schedule: quarterly diff --git a/example/example.py b/example/example.py index f8d1470a..6a039ef5 100644 --- a/example/example.py +++ b/example/example.py @@ -2,6 +2,8 @@ """ Example use of pypistats """ +from __future__ import annotations + import argparse from pprint import pprint # noqa: F401 diff --git a/pyproject.toml b/pyproject.toml index 8f195879..b91524f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,8 +72,31 @@ version.source = "vcs" [tool.hatch.version.raw-options] local_scheme = "no-local-version" -[tool.isort] -profile = "black" +[tool.ruff.lint] +select = [ + "C4", # flake8-comprehensions + "E", # pycodestyle errors + "EM", # flake8-errmsg + "F", # pyflakes errors + "I", # isort + "ISC", # flake8-implicit-str-concat + "LOG", # flake8-logging + "PGH", # pygrep-hooks + "RUF100", # unused noqa (yesqa) + "UP", # pyupgrade + "W", # pycodestyle warnings + "YTT", # flake8-2020 +] +extend-ignore = [ + "E203", # Whitespace before ':' + "E221", # Multiple spaces before operator + "E226", # Missing whitespace around arithmetic operator + "E241", # Multiple spaces after ',' +] + +[tool.ruff.lint.isort] +known-first-party = ["pypistats"] +required-imports = ["from __future__ import annotations"] [tool.pytest.ini_options] addopts = "--color=yes" diff --git a/scripts/run_command.py b/scripts/run_command.py index d8406bb0..5073cbcb 100644 --- a/scripts/run_command.py +++ b/scripts/run_command.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess diff --git a/src/pypistats/__init__.py b/src/pypistats/__init__.py index 8ed68568..c54c867e 100644 --- a/src/pypistats/__init__.py +++ b/src/pypistats/__init__.py @@ -2,6 +2,7 @@ Python interface to PyPI Stats API https://pypistats.org/api """ + from __future__ import annotations import atexit diff --git a/tests/data/expected_tabulated.py b/tests/data/expected_tabulated.py index d1b2d2fe..974efb38 100644 --- a/tests/data/expected_tabulated.py +++ b/tests/data/expected_tabulated.py @@ -1,3 +1,5 @@ +from __future__ import annotations + EXPECTED_TABULATED_HTML = """