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

Proposal: introduce Ruff and make mypy more strict #226

Open
mikeleppane opened this issue May 27, 2024 · 1 comment
Open

Proposal: introduce Ruff and make mypy more strict #226

mikeleppane opened this issue May 27, 2024 · 1 comment

Comments

@mikeleppane
Copy link

Hey!

What do you think, would it make sense to replace flake8 with Ruff and make mypy config more strict?

Running mypy in a more strict mode results in the following:

$ mypy src
...
Found 21 errors in 9 files (checked 36 source files)

And the same with Ruff:

$ ruff check src
... 
Found 90 errors.

Below is the used config (assuming the project supports any Python version from 3.8 onwards):

[tool.mypy]
# basic
python-version = "3.8"
exclude = ['^tests/assets/']

# be strict(ish)
disallow_untyped_calls = true
disallow_untyped_defs = true
check_untyped_defs = true
strict_equality = true
no_implicit_optional = true

# warnings
warn_unused_ignores = true
warn_unreachable = true
warn_redundant_casts = true
warn_unused_configs = true

[tool.ruff]
select = [
    "E",
    "F",
    "B",
    "W",
    "C4",
    "PIE",
    "RET",
    "SIM",
    "RUF",
    "C90",
    "UP",
    "ERA",
    "ARG",
    "TID",
    "PERF",
    "SLF",
    "PTH",
    "FURB",
    "I",
    "PL",
]

ignore = [
    "E501",    # line-too-long
    "PLR0913", # Too many arguments in function definition
    "PLR2004", # Magic value used in comparison"
]

# Exclude a variety of commonly ignored directories.
exclude = [".git", ".mypy_cache", ".ruff_cache"]
per-file-ignores = {}

# Same as Black.
line-length = 99

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.mccabe]
max-complexity = 10
@seddonym
Copy link
Owner

seddonym commented Jun 4, 2024

I like the idea, happy to consider a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants