Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace flake8 with ruff #46

Merged
merged 3 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test_with_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- run: tox -e py

- if: matrix.python == 3.10
run: TOXENV=flake8,manifest,docs,spell tox
run: TOXENV=ruff,manifest,docs,spell tox
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include README.md

include .bumpversion.cfg
include .codespellrc
include .flake8
include pyproject.toml
include tox.ini

recursive-include tests *.py
Expand Down
2 changes: 1 addition & 1 deletion dbutils/pooled_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
Licensed under the MIT license.
"""

from queue import Queue, Empty, Full
from queue import Empty, Full, Queue

from . import __version__
from .steady_pg import SteadyPgConnection
Expand Down
1 change: 1 addition & 0 deletions dbutils/steady_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def _ping_check(self, ping=1, reconnect=True):
self._store(con)
alive = True
return alive
return None

def dbapi(self):
"""Return the underlying DB-API 2 module of the connection."""
Expand Down
13 changes: 7 additions & 6 deletions docs/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from glob import glob
from os.path import splitext

from docutils.core import publish_file

print("Creating the documentation...")
Expand All @@ -25,11 +26,11 @@
output = publish_file(
writer_name='html5', source=source, destination=destination,
enable_exit_status=True,
settings_overrides=dict(
stylesheet_path='doc.css',
embed_stylesheet=False,
toc_backlinks=False,
language_code=lang,
exit_status_level=2))
settings_overrides={
"stylesheet_path": 'doc.css',
"embed_stylesheet": False,
"toc_backlinks": False,
"language_code": lang,
"exit_status_level": 2})

print("Done.")
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[tool.ruff]
select = [
"A", # flake8-builtins
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
"DTZ", # flake8-datetimez
"E", # pycodestyle
"EXE", # flake8-executable
"F", # Pyflakes
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"T10", # flake8-debugger
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
# "ANN", # flake8-annotations
# "BLE", # flake8-blind-except
# "COM", # flake8-commas
# "D", # pydocstyle
# "DJ", # flake8-django
# "EM", # flake8-errmsg
# "ERA", # eradicate
# "FBT", # flake8-boolean-trap
# "NPY", # NumPy-specific rules
# "PD", # pandas-vet
# "Q", # flake8-quotes
# "SIM", # flake8-simplify
# "SLF", # flake8-self
# "T20", # flake8-print
# "TRY", # tryceratops
]
# When removing rules from the `ignore` list, do `ruff rule ARG002` to see the docs
ignore = [
"ARG002",
"B007",
"B904",
"E722",
"N811",
"N818",
"PIE790",
"PLR5501",
"PTH122",
"PTH123",
"S110",
]
line-length = 79
target-version = "py37"

[tool.ruff.mccabe]
max-complexity = 31

[tool.ruff.pylint]
allow-magic-value-types = ["int", "str"]
max-args = 12
max-branches = 41
max-statements = 95

[tool.ruff.per-file-ignores]
"docs/make.py" = ["INP001"]
"tests/*" = ["B023", "I001", "N8", "PGH004", "PLR0915", "PT009", "S101"]
"tests/mock_pg.py" = ["RET505"]
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python3

"""Setup Script for DBUtils"""

import warnings

try:
from setuptools import setup
except ImportError:
Expand Down
2 changes: 2 additions & 0 deletions tests/mock_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ def query(self, qstr):
raise InternalError
if qstr in ('begin', 'end', 'commit', 'rollback'):
self.session.append(qstr)
return None
elif qstr.startswith('select '):
self.num_queries += 1
return qstr[7:]
elif qstr.startswith('set '):
self.session.append(qstr[4:])
return None
else:
raise ProgrammingError

Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py3{6,7,8,9,10,11}, flake8, manifest, docs, spell
envlist = py3{6,7,8,9,10,11}, ruff, manifest, docs, spell

[testenv]
setenv =
Expand All @@ -14,11 +14,11 @@ deps = codespell
commands =
codespell .

[testenv:flake8]
[testenv:ruff]
basepython = python3.10
deps = flake8
deps = ruff
commands =
flake8 .
ruff .

[testenv:manifest]
basepython = python3.10
Expand Down