-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruff.toml
More file actions
108 lines (94 loc) · 5.3 KB
/
ruff.toml
File metadata and controls
108 lines (94 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
"vendor_files"
]
line-length = 120
indent-width = 4
target-version = "py312"
[lint]
select = ["ALL"]
ignore = [
# rules that conflict with the Ruff formatter https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191","E111","E114","E117","D206","Q000","Q001","Q002","Q003","COM812","COM819","ISC001","ISC002","E501",
"D100", # Docstrings are not always necessary for public modules
"D101", # Docstrings are not always necessary for public classes
"D102", # Docstrings are not always necessary for public methods
"D103", # Docstrings are not always necessary for public functions
"D104", # Docstrings are not always necessary for public packages
"D105", # Docstrings are not always necessary for magic methods
"D106", # Nested classes are usually library-specific and don't always require its own docstring
"D107", # Init shouldn't need its own docstring, those arguments can be captured in the class level docstring
"D203", # Ignore D203 because it's a bug https://github.com/PyCQA/pydocstyle/issues/141
"D213", # Ignore D213 because mutually exclusive with D212 https://stackoverflow.com/questions/45990301/pep257-d212-and-d213-conflicts
"D413", # Docstrings shouldn't have an extra blank line at the end...the PEP that Ruff cites for this rule says that...not sure why ruff is trying to force this
"EM101", # Code readability is more important than traceback readability. People can use their judgement here
"EM102", # Code readability is more important than traceback readability. People can use their judgement here
"EM103", # Code readability is more important than traceback readability. People can use their judgement here
"FIX002", # We allow leaving TODOs in the code
"G004", # We are not concerned about performance issues of using f-strings in logging statements. Nor do we care about using extras particularly much...for more detailed logging needs, structlog is preferred
"N999", # Ignoring this since we are using jinja templates in the directory path which will eventually turn into a valid module name. # TODO: make a task in downstream templates to remove this
"S101", # We do not use the -o optimize flag, so it's fine to use `assert` in the main code. It's especially helpful for static typing
"SIM102", # Nested if statements can be better analyzed by coverage detectors than compound statements
"TD002", # Adding author names to TODOs erodes shared ownership of codebase. Git history provides information about who originally created the TODO if that information is vitally needed
"TD003", # Up to the author's judgement whether a TODO requires a link to an issue or not
"TID252", # Sometimes it makes sense to use relative imports, that's a judgement call for us, not ruff
"TC006", # Adding quotes around classes unnecessarily confuses the IDE for automatic refactoring
"SIM114", # Using `or` statements to simplify this would confuse the coverage checker
]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = [
"T201", "T203", # don't automatically delete print statements, just warn about them
"RUF100", # don't automatically remove unnecessary suppressions, because that can leave behind a now-stale comment about why the suppression was originally added
"FURB136", "PLR1730", # don't automatically replace if statements with min/max functions. Sometimes the if statement is more readable or better for code coverage checking
]
# Allow unused variables if it's an underscore or double underscore.
dummy-variable-rgx = "^_$|^__$"
[lint.per-file-ignores]
"src/*/*/__init__.py" = ["F401"] # imported but unused is not applicable to init except for the very top level init of a library, where you must use __all__ to ensure that py.typed works correctly
"tests/**/__init__.py" = ["F401"] # imported but unused is not applicable to init in tests
"exceptions.py" = ["D100", "D101", "D102"] # Exceptions don't always require docstrings for modules, classes or methods
"constants.py" = ["D100"] # Constants don't always require docstrings for modules
[lint.isort]
force-single-line = true
[lint.flake8-builtins]
builtins-ignorelist = ["id"] # We use the id() builtin rarely enough that it's okay to shadow it
[lint.flake8-annotations]
mypy-init-return = true # we don't care about annotating all __init__ methods as returning None
suppress-none-returning = true # if a function can only return None, we're fine not explicitly annotating the return type
suppress-dummy-args = true # we don't need to annotate arguments we're not using
[format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"