Repository navigation
Expand file tree
/
Copy path.ruff.toml
More file actions
68 lines (59 loc) · 2.45 KB
/
Copy path.ruff.toml
File metadata and controls
68 lines (59 loc) · 2.45 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
# Per our style guide.
line-length = 80
# Per our oldest supported platform (currently Ubuntu 24.04 "Noble").
target-version = "py312"
[per-file-target-version]
# This is run using Apple Python, so must retain its antiquated spellings.
"multibody/parsing/package_downloader.py" = "py39"
[lint]
ignore = [
# "Checks for function definitions that use a loop variable." This is an
# easy bug to miss, but unfortunately the linter produces too many false
# positives in our unit tests that use a helper lambda inside a test loop.
"B023",
# "Checks for except clauses that catch all exceptions." In practice, all
# places this flags are false positives.
"BLE001",
# "Checks for unnecessary dict(), list() or tuple() calls that can be
# rewritten as empty literals." If it were only empty ones that got dinged,
# that would be fine, but it also rewrites `dict(a=1)` to `{"a": 1}` which
# is sometimes less readable.
"C408",
# "Using the root logger causes the messages to have no source information,
# making them less useful for debugging." All uses are in main programs.
"LOG015",
# "Checks for operations that compare a name to itself." Some of our types
# override equality, so our unit tests do a self-comparison frequently.
"PLR0124",
# "[Finds code] which can be replaced by next(iter(...))". Typical cases
# are in unit tests, where the next(...) spelling is harder to read.
"RUF015",
# "Checks for noqa directives that are no longer applicable." We can't use
# this because we have more linters than just `ruff`, and their noqa marks
# confuse this check.
"RUF100",
# "The exec() function is insecure as it allows for arbitrary code
# execution." The hazard is not relvant for us because Drake makes no
# security promises.
"S102",
# "Checks for if statements that can be replaced with bool." We have a
# handful of uses of these in our code, and all of them are written out
# longhand for clarity.
"SIM103",
# "Checks for str.format calls that can be replaced with f-strings."
# In many cases this is a good idea, but not universally.
"UP032",
]
# Enable import sorting.
extend-select = ["I"]
[lint.isort]
# Interleave "straight" imports and "from" imports alphabetically.
force-sort-within-sections = true
# Group these separately from third-party imports.
known-first-party = [
"doc",
"drake",
"examples",
"pydrake",
"tools",
]