Skip to content

Commit 2155bf1

Browse files
committed
Switch from flake8 to ruff
1 parent 8c09c70 commit 2155bf1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+284
-525
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17-
# flake8-commas is failing on Python 3.12
1817
DEFAULT_PYTHON: '3.13'
1918

2019
jobs:
@@ -55,9 +54,6 @@ jobs:
5554
export UV=$(which uv)
5655
make venv-install
5756
58-
- name: Run flake8
59-
run: uv run flake8 syncmaster/
60-
6157
- name: Run mypy
6258
run: uv run mypy --config-file ./pyproject.toml ./syncmaster/server
6359

.pre-commit-config.yaml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ repos:
3737
- id: chmod
3838
args: ['644']
3939
exclude_types: [shell]
40-
exclude: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py)$
40+
exclude: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py|tests/resources/file_df_connection/generate.*.py)$
4141
- id: chmod
4242
args: ['755']
4343
types: [shell]
4444
- id: chmod
4545
args: ['755']
46-
files: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py)$
46+
files: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py|tests/resources/file_df_connection/generate.*.py)$
4747
- id: insert-license
4848
types: [python]
4949
exclude: ^(syncmaster/server/dependencies/stub.py|docs/.*\.py|tests/.*\.py)$
@@ -59,31 +59,15 @@ repos:
5959
- id: pyupgrade
6060
args: [--py311-plus, --keep-runtime-typing]
6161

62-
- repo: https://github.com/pycqa/bandit
63-
rev: 1.9.2
64-
hooks:
65-
- id: bandit
66-
args:
67-
- --aggregate=file
68-
- -iii
69-
- -ll
70-
require_serial: true
71-
7262
- repo: https://github.com/astral-sh/ruff-pre-commit
7363
rev: v0.14.10
7464
hooks:
7565
- id: ruff-format
66+
- id: ruff-check
67+
args: [--fix]
7668

7769
- repo: local
7870
hooks:
79-
- id: flake8
80-
name: flake8
81-
entry: flake8
82-
language: python
83-
types: [python]
84-
files: ^syncmaster/.*$
85-
pass_filenames: true
86-
8771
- id: mypy
8872
name: mypy
8973
entry: mypy ./syncmaster/server --config-file ./pyproject.toml
@@ -115,7 +99,6 @@ repos:
11599

116100
ci:
117101
skip:
118-
- flake8 # checked with Github Actions
119102
- mypy # checked with Github Actions
120103
- chmod # failing in pre-commit.ci
121104
- docker-compose-check # cannot run on pre-commit.ci

docker/download_ivy2_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_worker_spark_session_for_docker(connection_types: set[str]) -> SparkSess
3939
Construct dummy Spark session with all .jars included.
4040
Designed to be used in Dockerfile.worker to populate the image.
4141
"""
42-
from pyspark.sql import SparkSession
42+
from pyspark.sql import SparkSession # noqa: PLC0415
4343

4444
spark_builder = SparkSession.builder.appName("syncmaster_jar_downloader").master("local[1]")
4545

pyproject.toml

Lines changed: 38 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ test = [
108108
dev = [
109109
"mypy~=1.19.1",
110110
"pre-commit~=4.5.0",
111-
"flake8~=7.3.0",
112-
"flake8-pyproject~=1.2.3",
113111
"sqlalchemy[mypy]~=2.0.44",
114112
"types-jwcrypto~=1.5.0",
115113
]
@@ -137,6 +135,44 @@ target-version = "py311"
137135
line-length = 120
138136
extend-exclude = ["docs/", "Makefile"]
139137

138+
[tool.ruff.lint]
139+
select = ["ALL"]
140+
ignore = ["ARG", "ANN", "A002", "COM812", "D", "TD", "FIX002"]
141+
142+
[tool.ruff.lint.per-file-ignores]
143+
"syncmaster/db/migrations/versions/2025-08-10_0012_update_ts.py" = ["E501"]
144+
"syncmaster/db/migrations/*" = ["N999"]
145+
"syncmaster/db/models/*" = ["TC"]
146+
"syncmaster/db/repositories/*" = ["TC", "PLR0913"]
147+
"syncmaster/schemas/*" = ["TC"]
148+
149+
"tests/*" = [
150+
"S",
151+
"A",
152+
"E501",
153+
"FBT001",
154+
"FBT002",
155+
"PLR2004",
156+
"PLR0913",
157+
"SLF001",
158+
"FIX002",
159+
"PERF401",
160+
"RET504",
161+
"PLC0415",
162+
"C408",
163+
]
164+
"tests/resources/file_df_connection/test_data.py" = ["RUF001"]
165+
166+
[tool.ruff.lint.flake8-pytest-style]
167+
parametrize-names-type = "list"
168+
parametrize-values-type = "list"
169+
parametrize-values-row-type = "tuple"
170+
171+
[tool.ruff.lint.flake8-quotes]
172+
inline-quotes = "double"
173+
multiline-quotes = "double"
174+
docstring-quotes = "double"
175+
140176
[tool.mypy]
141177
python_version = "3.11"
142178
plugins = ["pydantic.mypy", "sqlalchemy.ext.mypy.plugin"]
@@ -240,217 +276,6 @@ exclude_lines = [
240276
"def downgrade\\(\\)",
241277
]
242278

243-
[tool.flake8]
244-
jobs = 4
245-
# We don't control ones who use our code
246-
i-control-code = false
247-
# Max of noqa in a module
248-
max-noqa-comments = 10
249-
max-annotation-complexity = 4
250-
max-returns = 5
251-
max-awaits = 5
252-
max-local-variables = 20
253-
max-name-length = 65
254-
# Max of expressions in a function
255-
max-expressions = 15
256-
# Max args in a function
257-
max-arguments = 15
258-
# Max classes and functions in a single module
259-
max-module-members = 35
260-
max-import-from-members = 35
261-
max-methods = 25
262-
# Max line complexity measured in AST nodes
263-
max-line-complexity = 24
264-
# Max Jones Score for a module: the median of all lines complexity sum
265-
max-jones-score = 15
266-
# Max amount of cognitive complexity per function
267-
max-cognitive-score = 20
268-
# Max amount of cognitive complexity per module
269-
max-cognitive-average = 25
270-
max-imports = 25
271-
max-imported-names = 50
272-
# Max of expression usages in a module
273-
max-module-expressions = 15
274-
# Max of expression usages in a function
275-
max-function-expressions = 15
276-
max-base-classes = 5
277-
max-decorators = 6
278-
# Max of repeated string constants in your modules
279-
max-string-usages = 15
280-
max-try-body-length = 15
281-
max-asserts = 15
282-
# Max number of access level in an expression
283-
max-access-level = 6
284-
# maximum number of public instance attributes
285-
max-attributes = 20
286-
287-
max-line-length = 120
288-
max-doc-length = 120
289-
290-
# https://pypi.org/project/flake8-quotes/
291-
inline-quotes = "double"
292-
multiline-quotes = "double"
293-
docstring-quotes = "double"
294-
295-
# https://wemake-python-stylegui.de/en/latest/pages/usage/formatter.html
296-
show-source = true
297-
# Print total number of errors
298-
count = true
299-
statistics = true
300-
301-
exclude = [
302-
".tox",
303-
"migrations",
304-
"dist",
305-
"build",
306-
"hadoop_archive_plugin",
307-
"virtualenv",
308-
"venv",
309-
"venv36",
310-
"ve",
311-
".venv",
312-
"tox.ini",
313-
"docker",
314-
"Jenkinsfile",
315-
"dags",
316-
"setup.py",
317-
"docs"
318-
]
319-
rst-directives = [
320-
"autosummary",
321-
"data",
322-
"currentmodule",
323-
"deprecated",
324-
"glossary",
325-
"moduleauthor",
326-
"plot",
327-
"testcode",
328-
"versionadded",
329-
"versionchanged"
330-
]
331-
# https://github.com/peterjc/flake8-rst-docstrings/pull/16
332-
rst-roles = [
333-
"attr",
334-
"class",
335-
"func",
336-
"meth",
337-
"mod",
338-
"obj",
339-
"ref",
340-
"term",
341-
"py:func",
342-
"py:mod"
343-
]
344-
345-
ignore = [
346-
"ANN",
347-
"FI1",
348-
# Found upper-case constant in a class: DB_URL
349-
"WPS115",
350-
# Found statement that has no effect
351-
"WPS428",
352-
# Found `f` string [opinionated]
353-
"WPS305",
354-
# Found class without a base class (goes against PEP8) [opinionated]
355-
"WPS306",
356-
# Found line break before binary operator [goes against PEP8] [opinionated]
357-
"W503",
358-
# Found multiline conditions [opinionated]
359-
"WPS337",
360-
# Found mutable module constant [opinionated]
361-
"WPS407",
362-
# Found empty module:
363-
"WPS411",
364-
# Found nested import [opinionated]
365-
"WPS433",
366-
# Found negated condition [opinionated]
367-
"WPS504",
368-
# Found implicit `.get()` dict usage
369-
"WPS529",
370-
# Docstrings [opinionated]
371-
"D",
372-
# string does contain unindexed parameters'
373-
"P101",
374-
"P103",
375-
# Found implicit string concatenation [optional]
376-
"WPS326",
377-
# Found wrong function call: locals'
378-
"WPS421",
379-
# module level import not at top of file
380-
"E402",
381-
# Document or section may not begin with a transition.
382-
"RST399",
383-
# Error in "code" directive
384-
"RST307",
385-
# Found `%` string formatting
386-
"WPS323",
387-
# doc line too long
388-
"W505",
389-
# line too long
390-
"E501",
391-
# Found wrong module name: util
392-
"WPS100",
393-
# Found wrong keyword: pass
394-
"WPS420",
395-
# Found incorrect node inside `class` body: pass
396-
"WPS604",
397-
# Found wrong variable name: data
398-
"WPS110",
399-
# Found builtin shadowing: id
400-
"WPS125",
401-
# Found too short name: e < 2
402-
"WPS111",
403-
# Found a line that starts with a dot
404-
"WPS348",
405-
# first argument of a method should be named 'self'
406-
"N805",
407-
# Found `finally` in `try` block without `except`
408-
"WPS501",
409-
# Wrong multiline string usage: textwrap.dedent + multiline comment
410-
"WPS462",
411-
# Found incorrect multi-line string: 3-quoted docstring with just one line
412-
"WPS322",
413-
# https://github.com/wemake-services/wemake-python-styleguide/issues/2847
414-
# E704 multiple statements on one line (def)
415-
"E704",
416-
# WPS220 Found too deep nesting: 34 > 20
417-
"WPS220",
418-
# WPS412 Found `__init__.py` module with logic
419-
"WPS412",
420-
# WPS410 Found wrong metadata variable: __all__
421-
"WPS410",
422-
]
423-
424-
per-file-ignores = [
425-
# WPS102 Found incorrect module name pattern
426-
# WPS432 Found magic number: 256
427-
# WPS226 Found string literal over-use: value > 15
428-
# WPS342 Found implicit raw string
429-
"*migrations/*.py:WPS102,WPS432,WPS226,WPS342",
430-
"*db/models/*.py:WPS102,WPS432,WPS342",
431-
"*db/mixins/*.py:WPS102,WPS432",
432-
# WPS432 Found magic number: 180
433-
"*settings/*.py:WPS432",
434-
# WPS404 Found complex default value
435-
"*server/api/*.py:WPS404",
436-
# WPS237 Found a too complex `f` string
437-
"*exceptions/*.py:WPS237",
438-
"*exceptions/__init__.py:F40,WPS410",
439-
# WPS201 Found module with too many imports: 30 > 25
440-
# WPS203 Found module with too many imported names: 55 > 50
441-
"syncmaster/worker/controller.py:WPS201,WPS203",
442-
# TAE001 too few type annotations
443-
# WPS231 Found function with too much cognitive complexity
444-
# S101 Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
445-
# WPS442 Found outer scope names shadowing
446-
# WPS432 Found magic number
447-
# WPS334 Found reversed complex comparison
448-
# WPS218 Found too many `assert` statements: 19 > 15
449-
# WPS226 Found string literal over-use: value > 15
450-
# WPS118 Found too long name:
451-
"*tests/*.py:TAE001,WPS231,S101,WPS442,WPS432,WPS334,WPS218,WPS226,WPS118",
452-
]
453-
454279
[tool.towncrier]
455280
name = "Syncmaster"
456281
package = "syncmaster"

syncmaster/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
VERSION_FILE = Path(__file__).parent / "VERSION"
77
_raw_version = VERSION_FILE.read_text().strip()
88
# version always contain only release number like 0.0.1
9-
__version__ = ".".join(_raw_version.split(".")[:3]) # noqa: WPS410
9+
__version__ = ".".join(_raw_version.split(".")[:3])
1010
# version tuple always contains only integer parts, like (0, 0, 1)
1111
__version_tuple__ = tuple(map(int, __version__.split("."))) # noqa: RUF048

0 commit comments

Comments
 (0)