mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Migrate from Black to Ruff and reformat code with enabling additional linter checks
This commit is contained in:
parent
a4a3f42c71
commit
d0bc165963
214 changed files with 916 additions and 963 deletions
|
|
@ -94,8 +94,6 @@ docs = [
|
|||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"black~=25.9",
|
||||
"isort~=7.0",
|
||||
"ruff~=0.14",
|
||||
"mypy==1.10.1",
|
||||
"toml~=0.10.2",
|
||||
|
|
@ -139,16 +137,38 @@ exclude = [
|
|||
[tool.ruff.lint]
|
||||
select = [
|
||||
# "C", # TODO: mccabe - code complecity
|
||||
"C4",
|
||||
"E",
|
||||
"F",
|
||||
"Q",
|
||||
"RET",
|
||||
"T10",
|
||||
"T20",
|
||||
"A", # flake8-annotations
|
||||
"B", # flake8-bugbear
|
||||
"C4", # flake8-comprehensions
|
||||
"DTZ", # flake8-datetimez
|
||||
"E", # pycodestyle errors
|
||||
"F", # pyflakes
|
||||
"I", # isort
|
||||
"PERF", # perflint
|
||||
"PL", # pylint
|
||||
"Q", # flake8-quotes
|
||||
"RET", # flake8-return
|
||||
"SIM", # flake8-simplify
|
||||
"T10", # flake8-debugger
|
||||
"T20", # flake8-print
|
||||
"UP", # pyupgrade
|
||||
]
|
||||
ignore = [
|
||||
"F401",
|
||||
"F401", # unused-import (handled by other tools)
|
||||
"A002", # builtin-argument-shadowing (common in API: type, id, format, etc.)
|
||||
"A005", # stdlib-module-shadowing (Module `types` shadows a Python standard-library module)
|
||||
"B008", # function-call-in-default-argument (Pydantic Field() defaults)
|
||||
"PLC0415", # import-outside-top-level (needed for circular imports)
|
||||
"PLC1901", # compare-to-empty-string (sometimes more explicit is better)
|
||||
"PLR0904", # too-many-public-methods (Bot class has many API methods)
|
||||
"PLR0911", # too-many-return-statements
|
||||
"PLR0912", # too-many-branches
|
||||
"PLR0913", # too-many-arguments (Telegram API methods have many params)
|
||||
"PLR0915", # too-many-statements
|
||||
"PLR0917", # too-many-positional-arguments (Telegram API design)
|
||||
"PLR6301", # no-self-use (sometimes methods are intentionally not static)
|
||||
"PLW2901", # redefined-loop-name (intentional pattern in this codebase)
|
||||
"PLW3201", # bad-dunder-method-name (custom dunders for framework design)
|
||||
]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
|
|
@ -164,6 +184,20 @@ known-first-party = [
|
|||
"aiogram/types/*" = ["E501"]
|
||||
"aiogram/methods/*" = ["E501"]
|
||||
"aiogram/enums/*" = ["E501"]
|
||||
"tests/**" = [
|
||||
"PLR0124",
|
||||
"PLR2004",
|
||||
"DTZ005",
|
||||
"DTZ006",
|
||||
"A001",
|
||||
"A004",
|
||||
"B018",
|
||||
"B020",
|
||||
"B904",
|
||||
"E501",
|
||||
"F821",
|
||||
"UP",
|
||||
]
|
||||
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
|
|
@ -174,7 +208,6 @@ testpaths = [
|
|||
filterwarnings = [
|
||||
"error",
|
||||
"ignore::pytest.PytestUnraisableExceptionWarning",
|
||||
|
||||
# Remove when uvloop fixes the issue
|
||||
# https://github.com/MagicStack/uvloop/issues/703
|
||||
# https://github.com/MagicStack/uvloop/pull/705
|
||||
|
|
@ -235,23 +268,10 @@ module = [
|
|||
ignore_missing_imports = true
|
||||
disallow_untyped_defs = true
|
||||
|
||||
[tool.black]
|
||||
line-length = 99
|
||||
target-version = ['py310', 'py311', 'py312', 'py313']
|
||||
exclude = '''
|
||||
(
|
||||
\.eggs
|
||||
| \.git
|
||||
| \.tox
|
||||
| build
|
||||
| dist
|
||||
| venv
|
||||
| docs
|
||||
)
|
||||
'''
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
[tool.ruff.format]
|
||||
quote-style = "double"
|
||||
indent-style = "space"
|
||||
line-ending = "auto"
|
||||
|
||||
[tool.towncrier]
|
||||
package = "aiogram"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue