Skip to content

Commit 6dc3643

Browse files
committed
Replace flake8 + isort + flynt with ruff
1 parent 5891109 commit 6dc3643

File tree

10 files changed

+59
-44
lines changed

10 files changed

+59
-44
lines changed

.flake8

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

.isort.cfg

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

dev_requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
build
22
black==24.3.0
33
click==8.0.4
4-
flake8-isort
5-
flake8
6-
flynt~=0.69.0
74
invoke==2.2.0
85
mock
96
packaging>=20.4
@@ -12,6 +9,7 @@ pytest-asyncio>=0.23.0,<0.24.0
129
pytest-cov
1310
pytest-profiling==1.8.1
1411
pytest-timeout
12+
ruff==0.9.6
1513
ujson>=4.2.0
1614
uvloop
1715
vulture>=2.3.0

doctests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pip uninstall -y redis # uninstall Redis package installed via redis-entraid
2121
pip install -r doctests/requirements.txt
2222
```
2323

24-
Note - the CI process, runs the basic ```black``` and ```isort``` linters against the examples. Assuming
25-
the requirements above have been installed you can run ```black yourfile.py``` and ```isort yourfile.py```
24+
Note - the CI process, runs linters against the examples. Assuming
25+
the requirements above have been installed you can run ```ruff check yourfile.py``` and ```ruff format yourfile.py```
2626
locally to validate the linting, prior to CI.
2727

2828
Just include necessary assertions in the example file and run

pyproject.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,54 @@ filterwarnings = [
9696
# Ignore a coverage warning when COVERAGE_CORE=sysmon for Pythons < 3.12.
9797
"ignore:sys.monitoring isn't available:coverage.exceptions.CoverageWarning",
9898
]
99+
100+
[tool.ruff]
101+
target-version = "py38"
102+
line-length = 88
103+
exclude = [
104+
"*.egg-info",
105+
"*.pyc",
106+
".git",
107+
".venv*",
108+
".venv*",
109+
"build",
110+
"dist",
111+
"docker",
112+
"docs/*",
113+
"doctests/*",
114+
"tasks.py",
115+
"venv*",
116+
"whitelist.py",
117+
]
118+
119+
[tool.ruff.lint]
120+
ignore = [
121+
"E501", # line too long (taken care of with ruff format)
122+
"E741", # ambiguous variable name
123+
"N818", # Errors should have Error suffix
124+
]
125+
126+
select = [
127+
"E",
128+
"F",
129+
"FLY",
130+
"I",
131+
"N",
132+
"W",
133+
]
134+
135+
[tool.ruff.lint.per-file-ignores]
136+
"redis/commands/bf/*" = [
137+
# the `bf` module uses star imports, so this is required there.
138+
"F405", # name may be undefined, or defined from star imports
139+
]
140+
"redis/commands/{bf,timeseries,json,search}/*" = [
141+
"N",
142+
]
143+
"tests/*" = [
144+
"I", # TODO: could be enabled, plenty of changes
145+
"N801", # class name should use CapWords convention
146+
"N803", # argument name should be lowercase
147+
"N802", # function name should be lowercase
148+
"N806", # variable name should be lowercase
149+
]

redis/asyncio/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ def __init__(
842842
if cert_reqs is None:
843843
self.cert_reqs = ssl.CERT_NONE
844844
elif isinstance(cert_reqs, str):
845-
CERT_REQS = {
845+
CERT_REQS = { # noqa: N806
846846
"none": ssl.CERT_NONE,
847847
"optional": ssl.CERT_OPTIONAL,
848848
"required": ssl.CERT_REQUIRED,

redis/asyncio/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def from_url(url, **kwargs):
1616
return Redis.from_url(url, **kwargs)
1717

1818

19-
class pipeline:
19+
class pipeline: # noqa: N801
2020
def __init__(self, redis_obj: "Redis"):
2121
self.p: "Pipeline" = redis_obj.pipeline()
2222

redis/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ def __init__(
10401040
if ssl_cert_reqs is None:
10411041
ssl_cert_reqs = ssl.CERT_NONE
10421042
elif isinstance(ssl_cert_reqs, str):
1043-
CERT_REQS = {
1043+
CERT_REQS = { # noqa: N806
10441044
"none": ssl.CERT_NONE,
10451045
"optional": ssl.CERT_OPTIONAL,
10461046
"required": ssl.CERT_REQUIRED,

redis/ocsp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from cryptography.hazmat.primitives.hashes import SHA1, Hash
1616
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
1717
from cryptography.x509 import ocsp
18+
1819
from redis.exceptions import AuthorizationError, ConnectionError
1920

2021

tasks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ def build_docs(c):
2727
@task
2828
def linters(c):
2929
"""Run code linters"""
30-
run("flake8 tests redis")
30+
run("ruff check tests redis")
3131
run("black --target-version py37 --check --diff tests redis")
32-
run("isort --check-only --diff tests redis")
3332
run("vulture redis whitelist.py --min-confidence 80")
34-
run("flynt --fail-on-change --dry-run tests redis")
3533

3634

3735
@task

0 commit comments

Comments
 (0)