Skip to content

Commit 6f52641

Browse files
authored
Replace flake8 with ruff (#46)
1 parent 705e940 commit 6f52641

File tree

10 files changed

+100
-17
lines changed

10 files changed

+100
-17
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/test_with_tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
- run: tox -e py
2323

2424
- if: matrix.python == 3.10
25-
run: TOXENV=flake8,manifest,docs,spell tox
25+
run: TOXENV=ruff,manifest,docs,spell tox

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include README.md
55

66
include .bumpversion.cfg
77
include .codespellrc
8-
include .flake8
8+
include pyproject.toml
99
include tox.ini
1010

1111
recursive-include tests *.py

dbutils/pooled_pg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
Licensed under the MIT license.
113113
"""
114114

115-
from queue import Queue, Empty, Full
115+
from queue import Empty, Full, Queue
116116

117117
from . import __version__
118118
from .steady_pg import SteadyPgConnection

dbutils/steady_db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def _ping_check(self, ping=1, reconnect=True):
372372
self._store(con)
373373
alive = True
374374
return alive
375+
return None
375376

376377
def dbapi(self):
377378
"""Return the underlying DB-API 2 module of the connection."""

docs/make.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from glob import glob
66
from os.path import splitext
7+
78
from docutils.core import publish_file
89

910
print("Creating the documentation...")
@@ -25,11 +26,11 @@
2526
output = publish_file(
2627
writer_name='html5', source=source, destination=destination,
2728
enable_exit_status=True,
28-
settings_overrides=dict(
29-
stylesheet_path='doc.css',
30-
embed_stylesheet=False,
31-
toc_backlinks=False,
32-
language_code=lang,
33-
exit_status_level=2))
29+
settings_overrides={
30+
"stylesheet_path": 'doc.css',
31+
"embed_stylesheet": False,
32+
"toc_backlinks": False,
33+
"language_code": lang,
34+
"exit_status_level": 2})
3435

3536
print("Done.")

pyproject.toml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[tool.ruff]
2+
select = [
3+
"A", # flake8-builtins
4+
"ARG", # flake8-unused-arguments
5+
"B", # flake8-bugbear
6+
"C4", # flake8-comprehensions
7+
"C90", # McCabe cyclomatic complexity
8+
"DTZ", # flake8-datetimez
9+
"E", # pycodestyle
10+
"EXE", # flake8-executable
11+
"F", # Pyflakes
12+
"G", # flake8-logging-format
13+
"I", # isort
14+
"ICN", # flake8-import-conventions
15+
"INP", # flake8-no-pep420
16+
"INT", # flake8-gettext
17+
"ISC", # flake8-implicit-str-concat
18+
"N", # pep8-naming
19+
"PGH", # pygrep-hooks
20+
"PIE", # flake8-pie
21+
"PL", # Pylint
22+
"PT", # flake8-pytest-style
23+
"PTH", # flake8-use-pathlib
24+
"PYI", # flake8-pyi
25+
"RET", # flake8-return
26+
"RSE", # flake8-raise
27+
"RUF", # Ruff-specific rules
28+
"S", # flake8-bandit
29+
"T10", # flake8-debugger
30+
"TCH", # flake8-type-checking
31+
"TID", # flake8-tidy-imports
32+
"UP", # pyupgrade
33+
"W", # pycodestyle
34+
"YTT", # flake8-2020
35+
# "ANN", # flake8-annotations
36+
# "BLE", # flake8-blind-except
37+
# "COM", # flake8-commas
38+
# "D", # pydocstyle
39+
# "DJ", # flake8-django
40+
# "EM", # flake8-errmsg
41+
# "ERA", # eradicate
42+
# "FBT", # flake8-boolean-trap
43+
# "NPY", # NumPy-specific rules
44+
# "PD", # pandas-vet
45+
# "Q", # flake8-quotes
46+
# "SIM", # flake8-simplify
47+
# "SLF", # flake8-self
48+
# "T20", # flake8-print
49+
# "TRY", # tryceratops
50+
]
51+
# When removing rules from the `ignore` list, do `ruff rule ARG002` to see the docs
52+
ignore = [
53+
"ARG002",
54+
"B007",
55+
"B904",
56+
"E722",
57+
"N811",
58+
"N818",
59+
"PIE790",
60+
"PLR5501",
61+
"PTH122",
62+
"PTH123",
63+
"S110",
64+
]
65+
line-length = 79
66+
target-version = "py37"
67+
68+
[tool.ruff.mccabe]
69+
max-complexity = 31
70+
71+
[tool.ruff.pylint]
72+
allow-magic-value-types = ["int", "str"]
73+
max-args = 12
74+
max-branches = 41
75+
max-statements = 95
76+
77+
[tool.ruff.per-file-ignores]
78+
"docs/make.py" = ["INP001"]
79+
"tests/*" = ["B023", "I001", "N8", "PGH004", "PLR0915", "PT009", "S101"]
80+
"tests/mock_pg.py" = ["RET505"]

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#!/usr/bin/env python3
2+
13
"""Setup Script for DBUtils"""
24

35
import warnings
6+
47
try:
58
from setuptools import setup
69
except ImportError:

tests/mock_pg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ def query(self, qstr):
5959
raise InternalError
6060
if qstr in ('begin', 'end', 'commit', 'rollback'):
6161
self.session.append(qstr)
62+
return None
6263
elif qstr.startswith('select '):
6364
self.num_queries += 1
6465
return qstr[7:]
6566
elif qstr.startswith('set '):
6667
self.session.append(qstr[4:])
68+
return None
6769
else:
6870
raise ProgrammingError
6971

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py3{6,7,8,9,10,11}, flake8, manifest, docs, spell
2+
envlist = py3{6,7,8,9,10,11}, ruff, manifest, docs, spell
33

44
[testenv]
55
setenv =
@@ -14,11 +14,11 @@ deps = codespell
1414
commands =
1515
codespell .
1616

17-
[testenv:flake8]
17+
[testenv:ruff]
1818
basepython = python3.10
19-
deps = flake8
19+
deps = ruff
2020
commands =
21-
flake8 .
21+
ruff .
2222

2323
[testenv:manifest]
2424
basepython = python3.10

0 commit comments

Comments
 (0)