-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruff.toml
More file actions
125 lines (115 loc) · 4.57 KB
/
ruff.toml
File metadata and controls
125 lines (115 loc) · 4.57 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# TorchMeter, AGPL-3.0 license
# Author: Ahzyuan
# Repo: https://github.com/TorchMeter/torchmeter
include = [
"torchmeter/**/*.py",
"tests/**/*.py",
"examples/**/*.py",
"examples/*/*.ipynb"
]
extend-exclude = [
"refers/**/*"
]
src=[".", "torchmeter/*"]
preview = true
line-length = 120 # Allow lines to be as long as 120.
target-version = "py38" # Always generate Python 3.8-compatible code.
output-format = "grouped"
required-version = ">=0.6.0" # ruff version
# =========================================== Linter ===========================================
[lint]
select = [
# flake8-builtins
"A",
# flake8-annotations
"ANN",
# flake8-unused-arguments
"ARG",
# mccabe
"C90",
# pycodestyle
"E",
# Pyflakes
"F",
# isort
"I",
# flake8-no-pep420
"INP",
# flake8-implicit-str-concat
# "ISC",
# flake8-pie
"PIE",
# flake8-pytest-style
"PT",
# Error
"PLE",
# ruff-specific rules
"RUF",
# flake8-simplify
"SIM",
# flake8-2020
"YTT"
]
extend-select = [
"ISC001", # Implicitly concatenated string literals on one line
"Q004", # Unnecessary escape on inner quote character
"DOC201", # return is not documented in docstring
"DOC402", # yield is not documented in docstring
"DOC403", # Docstring has a "Yields" section but the function doesn't yield anything
"DOC501", # Raised exception {id} missing from docstring
]
# Skip unused variable rules
ignore = [
"ANN002", # Missing type annotation for *{name}
"ANN003", # Missing type annotation for **{name}
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {name}
"E111", # Indentation is not a multiple of {indent_width}
"E114", # Indentation is not a multiple of {indent_width} (comment)
"E117", # Over-indented (comment)
"E261", # Insert at least two spaces before an inline comment
"E731", # Allow lambda expressions
"FA102", # Missing from __future__ import annotations, but uses {reason}
"PIE790", # Unnecessary pass statement
"PIE794", # Class field {name} is defined multiple times
"PIE810", # Call {attr} once with a tuple
"PLE0101", # Explicit return in __init__
"PT007", # Wrong values type in pytest.mark.parametrize expected {values} of {row}
"PT008", # Use return_value= instead of patching with lambda
"PT009", # Use a regular assert instead of unittest-style {assertion}
"PT011", # pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception
"PT012", # pytest.raises() block should contain a single simple statement
"PT019", # Fixture {name} without value is injected as parameter, use @pytest.mark.usefixtures instead
"PT021", # Use yield instead of request.addfinalizer
"PT023", # Use @pytest.mark.{mark_name}{expected_parens} over @pytest.mark.{mark_name}{actual_parens}
"RUF022", # __all__ is not sorted
"RUF023", # {}.__slots__ is not sorted
"RUF031", # Use parentheses for tuples in subscripts
"RUF034", # Useless if-else condition
"RUF052", # Local dummy variable {} is accessed
"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
"SIM107", # Don't use return in try-except and finally
"SIM910", # Use {expected} instead of {actual}
"W191", # Indentation contains tabs
]
unfixable = ["E501"] # long lines should be wrapped manually
[lint.per-file-ignores]
"*.ipynb" = ["E402"] # Module level import not at top of cell
"tests/**/*.py" = [
"ANN001", # Missing type annotation for function argument {name}
"ANN201", # Missing return type annotation for public function {name}
"ANN202", # Missing return type annotation for private function {name}
"ARG002", # Unused method argument: {name}
"ARG005", # Unused lambda argument: {name}
"PT030", # pytest.warns({warning}) is too broad, set the match parameter or use a more specific warning
"PT031", # pytest.warns() block should contain a single simple statement
"DOC" # pydoclint
]
[lint.flake8-implicit-str-concat]
allow-multiline = true
[lint.isort]
length-sort = true # sort imports by their string length
known-first-party = ["torchmeter"]
# =========================================== Formatter ===========================================
[format]
quote-style = "double"
docstring-code-format = true # Enable reformatting of code snippets in docstrings.