Skip to content

Commit d539efa

Browse files
committed
Minor update of ruff rules, removed init in src
1 parent 80aec24 commit d539efa

File tree

2 files changed

+110
-33
lines changed

2 files changed

+110
-33
lines changed

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 110 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -73,54 +73,134 @@ exclude = "^build/|^docs/"
7373
[tool.doc8]
7474
max-line-length = 1000
7575

76-
[tool.black]
77-
line-length = 100
78-
target-version = ["py311"]
79-
8076
[tool.nbqa.exclude]
8177
ruff = "\\.jupyter_cache|jupyter_execute"
8278
mypy = "\\.jupyter_cache|jupyter_execute"
8379

80+
81+
[tool.black]
82+
line-length = 140
83+
target-version = ["py311"]
84+
8485
[tool.ruff]
86+
target-version = "py311"
87+
line-length = 140
88+
89+
[tool.ruff.lint]
8590
select = [
86-
"ASYNC", "B", "C4", "C90", "COM", "D", "DTZ", "E", "F", "FLY", "G", "I", "ISC", "PIE", "PLC", "PLE", "PLW", "RET", "RUF", "RSE", "SIM", "TID", "UP", "W", "YTT",
91+
"ASYNC",
92+
"B",
93+
"C4",
94+
"C90",
95+
"COM",
96+
"D",
97+
"DTZ",
98+
"E",
99+
"F",
100+
"FLY",
101+
"G",
102+
"I",
103+
"ISC",
104+
"PIE",
105+
"PLC",
106+
"PLE",
107+
"PLW",
108+
"RET",
109+
"RUF",
110+
"RSE",
111+
"SIM",
112+
"TID",
113+
"UP",
114+
"W",
115+
"YTT",
87116
]
88117
ignore = [
89-
"COM812", # requires trailing commas and can cause undesirable reformats when calling `poe format` multiple times (see https://github.com/appliedAI-Initiative/pymetrius/issues/17)
90-
"E501", # line too long. black does a good enough job
91-
"E741", # variable names like "l". this isn't a huge problem
92-
"B008", # do not perform function calls in argument defaults. we do this sometimes
93-
"B011", # assert false. we don't use python -O
94-
"B028", # we don't need explicit stacklevel for warnings
95-
"D100", "D101", "D102", "D104", "D105", "D107", "D203", "D213", "D401", "D402", # docstring stuff
96-
"DTZ005", # we don't need that
97-
# remaining rules from https://github.com/psf/black/blob/main/.flake8 (except W503)
98-
# this is a simplified version of config, making vscode plugin happy
99-
"E402", "E501", "E701", "E731", "C408", "E203",
100-
# Logging statement uses f-string warning
101-
"G004",
102-
# Unnecessary `elif` after `return` statement
103-
"RET505",
104-
"D106", # undocumented public nested class
105-
"D205", # blank line after summary (prevents summary-only docstrings, which makes no sense)
118+
"RUF002", # hyphen checks
119+
"RUF005", # unpacking over concatenation (no point in that rule IMO)
120+
"SIM118", # Needed b/c iter(batch) != iter(batch.keys()). See https://github.com/thu-ml/tianshou/issues/922
121+
"SIM108", # if - else is fine
122+
"E501", # line too long. black does a good enough job
123+
"E741", # variable names like "l". this isn't a huge problem
124+
"B008", # do not perform function calls in argument defaults. we do this sometimes
125+
"B011", # assert false. we don't use python -O
126+
"B028", # we don't need explicit stacklevel for warnings
127+
"D100",
128+
"D101",
129+
"D102",
130+
"D103",
131+
"D104",
132+
"D105",
133+
"D107",
134+
"D200",
135+
"D203",
136+
"D213",
137+
"D401",
138+
"D402", # docstring stuff
139+
"DTZ005", # we don't need that
140+
# remaining rules from https://github.com/psf/black/blob/main/.flake8 (except W503)
141+
# this is a simplified version of config, making vscode plugin happy
142+
"E402",
143+
"E501",
144+
"E701",
145+
"E731",
146+
"C408",
147+
"E203",
148+
# Logging statement uses f-string warning
149+
"G004",
150+
# Unnecessary `elif` after `return` statement
151+
"RET505",
152+
"D106", # undocumented public nested class
153+
"D205", # blank line after summary (prevents summary-only docstrings, which makes no sense)
154+
"D212", # no blank line after """. This clashes with sphinx for multiline descriptions of :param: that start directly after """
155+
"PLW2901", # overwrite vars in loop
156+
"B027", # empty and non-abstract method in abstract class
157+
"D404", # It's fine to start with "This" in docstrings
158+
"D407",
159+
"D408",
160+
"D409", # Ruff rules for underlines under 'Example:' and so clash with Sphinx
161+
"D400", # Period at the end of docstring
162+
"D415", # Closing punctuation
163+
"COM812", # missing trailing comma: With this enabled, re-application of "poe format" chain can cause additional commas and subsequent reformatting
164+
"RET503", # no need to return None
165+
"RET504", # it is fine to return after creation
166+
"UP038", # tuples in isinstance
167+
"F403", "F405", # star imports
168+
"C401", # generators
169+
"C901", # complexity analysis
170+
106171
]
107172
unfixable = [
108-
173+
"F841", # unused variable. ruff keeps the call, but mostly we want to get rid of it all
174+
"F601", # automatic fix might obscure issue
175+
"F602", # automatic fix might obscure issue
176+
"B018", # automatic fix might obscure issue
109177
]
110178
extend-fixable = [
111-
"F401", # unused import
112-
"B905", # bugbear
179+
"F401", # unused import
180+
"B905", # bugbear
181+
"W291", # trailing whitespace
113182
]
114183

115-
target-version = "py311"
184+
185+
[tool.ruff.lint.per-file-ignores]
186+
"tests/**" = ["D103"]
187+
"docs/**" = ["D103"]
188+
"examples/**" = ["D103"]
189+
"scripts/**" = ["D103"]
190+
191+
192+
[tool.ruff.format]
193+
# configuration to match the Black settings
194+
quote-style = "double"
195+
indent-style = "space"
196+
line-ending = "auto"
197+
skip-magic-trailing-comma = false
198+
docstring-code-format = true
199+
116200

117201
[tool.ruff.mccabe]
118202
max-complexity = 20
119203

120-
[tool.ruff.per-file-ignores]
121-
"test/**" = ["D103"]
122-
"docs/**" = ["D103"]
123-
"examples/**" = ["D103"]
124204

125205
[tool.poetry_bumpversion.file."{{cookiecutter.package_name}}/__init__.py"]
126206

@@ -132,8 +212,6 @@ PYDEVD_DISABLE_FILE_VALIDATION="1"
132212
# keep relevant parts in sync with pre-commit
133213
[tool.poe.tasks] # https://github.com/nat-n/poethepoet
134214
test = "pytest test --cov={{cookiecutter.package_name}} --cov-report=xml --cov-report=term-missing --durations=0 -v --color=yes"
135-
# Adjust to a smaller set of tests if appropriate
136-
test-subset = "pytest test --color=yes"
137215
_black_check = "black --check ."
138216
_ruff_check = "ruff check ."
139217
_ruff_check_nb = "nbqa ruff docs"

{{cookiecutter.project_name}}/src/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)