Skip to content
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 .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ concurrency:
cancel-in-progress: true

env:
# flake8-commas is failing on Python 3.12
DEFAULT_PYTHON: '3.13'

jobs:
Expand Down Expand Up @@ -55,9 +54,6 @@ jobs:
export UV=$(which uv)
make venv-install

- name: Run flake8
run: uv run flake8 syncmaster/

- name: Run mypy
run: uv run mypy --config-file ./pyproject.toml ./syncmaster/server

Expand Down
25 changes: 4 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ repos:
- id: chmod
args: ['644']
exclude_types: [shell]
exclude: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py)$
exclude: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py|tests/resources/file_df_connection/generate.*.py)$
- id: chmod
args: ['755']
types: [shell]
- id: chmod
args: ['755']
files: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py)$
files: ^(.*__main__\.py|syncmaster/server/scripts/.*\.py|docker/.*\.py|tests/resources/file_df_connection/generate.*.py)$
- id: insert-license
types: [python]
exclude: ^(syncmaster/server/dependencies/stub.py|docs/.*\.py|tests/.*\.py)$
Expand All @@ -59,31 +59,15 @@ repos:
- id: pyupgrade
args: [--py311-plus, --keep-runtime-typing]

- repo: https://github.com/pycqa/bandit
rev: 1.9.2
hooks:
- id: bandit
args:
- --aggregate=file
- -iii
- -ll
require_serial: true

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10
hooks:
- id: ruff-format
- id: ruff-check
args: [--fix]

- repo: local
hooks:
- id: flake8
name: flake8
entry: flake8
language: python
types: [python]
files: ^syncmaster/.*$
pass_filenames: true

- id: mypy
name: mypy
entry: mypy ./syncmaster/server --config-file ./pyproject.toml
Expand Down Expand Up @@ -115,7 +99,6 @@ repos:

ci:
skip:
- flake8 # checked with Github Actions
- mypy # checked with Github Actions
- chmod # failing in pre-commit.ci
- docker-compose-check # cannot run on pre-commit.ci
2 changes: 1 addition & 1 deletion docker/download_ivy2_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_worker_spark_session_for_docker(connection_types: set[str]) -> SparkSess
Construct dummy Spark session with all .jars included.
Designed to be used in Dockerfile.worker to populate the image.
"""
from pyspark.sql import SparkSession
from pyspark.sql import SparkSession # noqa: PLC0415

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

Expand Down
251 changes: 38 additions & 213 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ test = [
dev = [
"mypy~=1.19.1",
"pre-commit~=4.5.0",
"flake8~=7.3.0",
"flake8-pyproject~=1.2.3",
"sqlalchemy[mypy]~=2.0.44",
"types-jwcrypto~=1.5.0",
]
Expand Down Expand Up @@ -137,6 +135,44 @@ target-version = "py311"
line-length = 120
extend-exclude = ["docs/", "Makefile"]

[tool.ruff.lint]
select = ["ALL"]
ignore = ["ARG", "ANN", "A002", "COM812", "D", "TD", "FIX002"]

[tool.ruff.lint.per-file-ignores]
"syncmaster/db/migrations/versions/2025-08-10_0012_update_ts.py" = ["E501"]
"syncmaster/db/migrations/*" = ["N999"]
"syncmaster/db/models/*" = ["TC"]
"syncmaster/db/repositories/*" = ["TC", "PLR0913"]
"syncmaster/schemas/*" = ["TC"]

"tests/*" = [
"S",
"A",
"E501",
"FBT001",
"FBT002",
"PLR2004",
"PLR0913",
"SLF001",
"FIX002",
"PERF401",
"RET504",
"PLC0415",
"C408",
]
"tests/resources/file_df_connection/test_data.py" = ["RUF001"]

[tool.ruff.lint.flake8-pytest-style]
parametrize-names-type = "list"
parametrize-values-type = "list"
parametrize-values-row-type = "tuple"

[tool.ruff.lint.flake8-quotes]
inline-quotes = "double"
multiline-quotes = "double"
docstring-quotes = "double"

[tool.mypy]
python_version = "3.11"
plugins = ["pydantic.mypy", "sqlalchemy.ext.mypy.plugin"]
Expand Down Expand Up @@ -240,217 +276,6 @@ exclude_lines = [
"def downgrade\\(\\)",
]

[tool.flake8]
jobs = 4
# We don't control ones who use our code
i-control-code = false
# Max of noqa in a module
max-noqa-comments = 10
max-annotation-complexity = 4
max-returns = 5
max-awaits = 5
max-local-variables = 20
max-name-length = 65
# Max of expressions in a function
max-expressions = 15
# Max args in a function
max-arguments = 15
# Max classes and functions in a single module
max-module-members = 35
max-import-from-members = 35
max-methods = 25
# Max line complexity measured in AST nodes
max-line-complexity = 24
# Max Jones Score for a module: the median of all lines complexity sum
max-jones-score = 15
# Max amount of cognitive complexity per function
max-cognitive-score = 20
# Max amount of cognitive complexity per module
max-cognitive-average = 25
max-imports = 25
max-imported-names = 50
# Max of expression usages in a module
max-module-expressions = 15
# Max of expression usages in a function
max-function-expressions = 15
max-base-classes = 5
max-decorators = 6
# Max of repeated string constants in your modules
max-string-usages = 15
max-try-body-length = 15
max-asserts = 15
# Max number of access level in an expression
max-access-level = 6
# maximum number of public instance attributes
max-attributes = 20

max-line-length = 120
max-doc-length = 120

# https://pypi.org/project/flake8-quotes/
inline-quotes = "double"
multiline-quotes = "double"
docstring-quotes = "double"

# https://wemake-python-stylegui.de/en/latest/pages/usage/formatter.html
show-source = true
# Print total number of errors
count = true
statistics = true

exclude = [
".tox",
"migrations",
"dist",
"build",
"hadoop_archive_plugin",
"virtualenv",
"venv",
"venv36",
"ve",
".venv",
"tox.ini",
"docker",
"Jenkinsfile",
"dags",
"setup.py",
"docs"
]
rst-directives = [
"autosummary",
"data",
"currentmodule",
"deprecated",
"glossary",
"moduleauthor",
"plot",
"testcode",
"versionadded",
"versionchanged"
]
# https://github.com/peterjc/flake8-rst-docstrings/pull/16
rst-roles = [
"attr",
"class",
"func",
"meth",
"mod",
"obj",
"ref",
"term",
"py:func",
"py:mod"
]

ignore = [
"ANN",
"FI1",
# Found upper-case constant in a class: DB_URL
"WPS115",
# Found statement that has no effect
"WPS428",
# Found `f` string [opinionated]
"WPS305",
# Found class without a base class (goes against PEP8) [opinionated]
"WPS306",
# Found line break before binary operator [goes against PEP8] [opinionated]
"W503",
# Found multiline conditions [opinionated]
"WPS337",
# Found mutable module constant [opinionated]
"WPS407",
# Found empty module:
"WPS411",
# Found nested import [opinionated]
"WPS433",
# Found negated condition [opinionated]
"WPS504",
# Found implicit `.get()` dict usage
"WPS529",
# Docstrings [opinionated]
"D",
# string does contain unindexed parameters'
"P101",
"P103",
# Found implicit string concatenation [optional]
"WPS326",
# Found wrong function call: locals'
"WPS421",
# module level import not at top of file
"E402",
# Document or section may not begin with a transition.
"RST399",
# Error in "code" directive
"RST307",
# Found `%` string formatting
"WPS323",
# doc line too long
"W505",
# line too long
"E501",
# Found wrong module name: util
"WPS100",
# Found wrong keyword: pass
"WPS420",
# Found incorrect node inside `class` body: pass
"WPS604",
# Found wrong variable name: data
"WPS110",
# Found builtin shadowing: id
"WPS125",
# Found too short name: e < 2
"WPS111",
# Found a line that starts with a dot
"WPS348",
# first argument of a method should be named 'self'
"N805",
# Found `finally` in `try` block without `except`
"WPS501",
# Wrong multiline string usage: textwrap.dedent + multiline comment
"WPS462",
# Found incorrect multi-line string: 3-quoted docstring with just one line
"WPS322",
# https://github.com/wemake-services/wemake-python-styleguide/issues/2847
# E704 multiple statements on one line (def)
"E704",
# WPS220 Found too deep nesting: 34 > 20
"WPS220",
# WPS412 Found `__init__.py` module with logic
"WPS412",
# WPS410 Found wrong metadata variable: __all__
"WPS410",
]

per-file-ignores = [
# WPS102 Found incorrect module name pattern
# WPS432 Found magic number: 256
# WPS226 Found string literal over-use: value > 15
# WPS342 Found implicit raw string
"*migrations/*.py:WPS102,WPS432,WPS226,WPS342",
"*db/models/*.py:WPS102,WPS432,WPS342",
"*db/mixins/*.py:WPS102,WPS432",
# WPS432 Found magic number: 180
"*settings/*.py:WPS432",
# WPS404 Found complex default value
"*server/api/*.py:WPS404",
# WPS237 Found a too complex `f` string
"*exceptions/*.py:WPS237",
"*exceptions/__init__.py:F40,WPS410",
# WPS201 Found module with too many imports: 30 > 25
# WPS203 Found module with too many imported names: 55 > 50
"syncmaster/worker/controller.py:WPS201,WPS203",
# TAE001 too few type annotations
# WPS231 Found function with too much cognitive complexity
# S101 Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
# WPS442 Found outer scope names shadowing
# WPS432 Found magic number
# WPS334 Found reversed complex comparison
# WPS218 Found too many `assert` statements: 19 > 15
# WPS226 Found string literal over-use: value > 15
# WPS118 Found too long name:
"*tests/*.py:TAE001,WPS231,S101,WPS442,WPS432,WPS334,WPS218,WPS226,WPS118",
]

[tool.towncrier]
name = "Syncmaster"
package = "syncmaster"
Expand Down
2 changes: 1 addition & 1 deletion syncmaster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
VERSION_FILE = Path(__file__).parent / "VERSION"
_raw_version = VERSION_FILE.read_text().strip()
# version always contain only release number like 0.0.1
__version__ = ".".join(_raw_version.split(".")[:3]) # noqa: WPS410
__version__ = ".".join(_raw_version.split(".")[:3])
# version tuple always contains only integer parts, like (0, 0, 1)
__version_tuple__ = tuple(map(int, __version__.split("."))) # noqa: RUF048
Loading