Skip to content

Commit

Permalink
Replace Flake8 with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Feb 3, 2024
1 parent 21528ae commit 1ce4df1
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

38 changes: 13 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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

Expand All @@ -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
2 changes: 2 additions & 0 deletions example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""
Example use of pypistats
"""
from __future__ import annotations

import argparse
from pprint import pprint # noqa: F401

Expand Down
27 changes: 25 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions scripts/run_command.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import subprocess


Expand Down
1 change: 1 addition & 0 deletions src/pypistats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Python interface to PyPI Stats API
https://pypistats.org/api
"""

from __future__ import annotations

import atexit
Expand Down
4 changes: 3 additions & 1 deletion tests/data/expected_tabulated.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

EXPECTED_TABULATED_HTML = """
<table>
<thead>
Expand Down Expand Up @@ -126,4 +128,4 @@
"3.7"\t"2018-08-15"\t6,595
"3.8"\t"2018-08-15"\t3
"null"\t"2018-08-15"\t1,019
""" # noqa: W291
"""
2 changes: 2 additions & 0 deletions tests/data/python_minor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

DATA = [
{"category": "2.4", "date": "2018-04-28", "downloads": 1},
{"category": "2.4", "date": "2018-06-08", "downloads": 1},
Expand Down
3 changes: 3 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Unit tests for cli
"""

from __future__ import annotations

import argparse

import pytest
Expand Down
3 changes: 3 additions & 0 deletions tests/test_pypistats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Unit tests for pypistats
"""

from __future__ import annotations

import copy
import json
from pathlib import Path
Expand Down
3 changes: 3 additions & 0 deletions tests/test_pypistats_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Unit tests for pypistats cache
"""

from __future__ import annotations

import tempfile
from pathlib import Path

Expand Down
2 changes: 2 additions & 0 deletions tests/test_pypistats_print.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import pypistats


Expand Down

0 comments on commit 1ce4df1

Please sign in to comment.