Skip to content

Commit b018940

Browse files
Update ruff to latest (#1933)
* Update ruff * rm Self --------- Co-authored-by: Shatakshi Mishra <[email protected]>
1 parent 8e9bcb3 commit b018940

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+285
-214
lines changed

.config/pydoclint-baseline.txt

Lines changed: 0 additions & 73 deletions
Large diffs are not rendered by default.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ repos:
4545
- id: toml-sort-fix
4646

4747
- repo: https://github.com/astral-sh/ruff-pre-commit
48-
rev: "v0.9.10"
48+
rev: "v0.11.2"
4949
hooks:
5050
- id: ruff
5151
args:

docs/_ext/regenerate_docs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def md_settings_dump() -> str:
101101

102102

103103
def _params_row_for_entry(entry: SettingsEntry) -> tuple[str, ...]:
104-
# pylint: disable=too-many-branches
105104
"""Create a row entry for one settings parameter.
106105
107106
:param entry: The settings entry for which the row will be generated

pyproject.toml

Lines changed: 133 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ allow-init-docstring = true
8585
arg-type-hints-in-docstring = false
8686
baseline = ".config/pydoclint-baseline.txt"
8787
check-return-types = false
88+
check-yield-types = false
8889
exclude = '\.git|\.test_logs|\.tox|build|out|tests/fixtures|venv'
8990
should-document-private-class-attributes = true
9091
show-filenames-in-every-violation-message = true
@@ -122,120 +123,225 @@ disable = [
122123
"fixme",
123124
"too-few-public-methods",
124125
"unsubscriptable-object",
126+
"unknown-option-value",
125127
# https://gist.github.com/cidrblock/ec3412bacfeb34dbc2d334c1d53bef83
126128
"C0103", # invalid-name / ruff N815
129+
"C0105", # typevar-name-incorrect-variance / ruff PLC0105
127130
"C0112", # empty-docstring / ruff D419
131+
"C0113", # unneeded-not / ruff SIM208
128132
"C0114", # missing-module-docstring / ruff D100
129133
"C0115", # missing-class-docstring / ruff D101
130134
"C0116", # missing-function-docstring / ruff D103
131135
"C0121", # singleton-comparison / ruff PLC0121
132136
"C0123", # unidiomatic-typecheck / ruff E721
133-
# "C0198", # bad-docstring-quotes / ruff Q002
134-
# "C0199", # docstring-first-line-empty / ruff D210
137+
"C0131", # typevar-double-variance / ruff PLC0131
138+
"C0132", # typevar-name-mismatch / ruff PLC0132
139+
"C0198", # bad-docstring-quotes / ruff Q002
140+
"C0199", # docstring-first-line-empty / ruff D210
141+
"C0201", # consider-iterating-dictionary / ruff SIM118
135142
"C0202", # bad-classmethod-argument / ruff PLC0202
143+
"C0205", # single-string-used-for-slots / ruff PLC0205
144+
"C0206", # consider-using-dict-items / ruff PLC0206
145+
"C0208", # use-sequence-for-iteration / ruff PLC0208
136146
"C0301", # line-too-long / ruff E501
147+
"C0303", # trailing-whitespace / ruff W291
137148
"C0304", # missing-final-newline / ruff W292
138-
"C0325", # superfluous-parens / ruff UP034
149+
"C0305", # trailing-newlines / ruff W391
150+
"C0321", # multiple-statements / ruff PLC0321
139151
"C0410", # multiple-imports / ruff E401
140152
"C0411", # wrong-import-order / ruff I001
141153
"C0412", # ungrouped-imports / ruff I001
142154
"C0413", # wrong-import-position / ruff E402
143155
"C0414", # useless-import-alias / ruff PLC0414
144-
# "C0501", # consider-using-any-or-all / ruff PLC0501
145-
# "C2201", # misplaced-comparison-constant / ruff SIM300
146-
"C3001", # unnecessary-lambda-assignment / ruff PLC3001
156+
"C0415", # import-outside-toplevel / ruff PLC0415
157+
"C0501", # consider-using-any-or-all / ruff PLC0501
158+
"C1802", # use-implicit-booleaness-not-len / ruff PLC1802
159+
"C1901", # compare-to-empty-string / ruff PLC1901
160+
"C2201", # misplaced-comparison-constant / ruff SIM300
161+
"C2401", # non-ascii-name / ruff PLC2401
162+
"C2403", # non-ascii-module-import / ruff PLC2403
163+
"C2701", # import-private-name / ruff PLC2701
164+
"C2801", # unnecessary-dunder-call / ruff PLC2801
165+
"C3001", # unnecessary-lambda-assignment / ruff E731
147166
"C3002", # unnecessary-direct-lambda-call / ruff PLC3002
148-
"E0001", # syntax-error / ruff E999
167+
"E0001", # syntax-error / ruff PLE0001
168+
"E0100", # init-is-generator / ruff PLE0100
149169
"E0101", # return-in-init / ruff PLE0101
150170
"E0102", # function-redefined / ruff F811
151171
"E0103", # not-in-loop / ruff PLE0103
152172
"E0104", # return-outside-function / ruff F706
153173
"E0105", # yield-outside-function / ruff F704
154174
"E0107", # nonexistent-operator / ruff B002
175+
"E0112", # too-many-star-expressions / ruff F622
176+
"E0115", # nonlocal-and-global / ruff PLE0115
155177
"E0116", # continue-in-finally / ruff PLE0116
156178
"E0117", # nonlocal-without-binding / ruff PLE0117
157179
"E0118", # used-prior-global-declaration / ruff PLE0118
158-
"E0211", # no-method-argument / ruff N805
159180
"E0213", # no-self-argument / ruff N805
181+
"E0237", # assigning-non-slot / ruff PLE0237
182+
"E0241", # duplicate-bases / ruff PLE0241
183+
"E0302", # unexpected-special-method-signature / ruff PLE0302
184+
"E0303", # invalid-length-returned / ruff PLE0303
185+
"E0304", # invalid-bool-returned / ruff PLE0304
186+
"E0305", # invalid-index-returned / ruff PLE0305
187+
"E0308", # invalid-bytes-returned / ruff PLE0308
188+
"E0309", # invalid-hash-returned / ruff PLE0309
189+
"E0402", # relative-beyond-top-level / ruff TID252
190+
"E0601", # used-before-assignment / ruff F821
160191
"E0602", # undefined-variable / ruff F821
192+
"E0603", # undefined-all-variable / ruff F822
161193
"E0604", # invalid-all-object / ruff PLE0604
162194
"E0605", # invalid-all-format / ruff PLE0605
195+
"E0643", # potential-index-error / ruff PLE0643
196+
"E0704", # misplaced-bare-raise / ruff PLE0704
163197
"E0711", # notimplemented-raised / ruff F901
164-
"E1133", # not-an-iterable
198+
"E1132", # repeated-keyword / ruff PLE1132
165199
"E1142", # await-outside-async / ruff PLE1142
166200
"E1205", # logging-too-many-args / ruff PLE1205
167201
"E1206", # logging-too-few-args / ruff PLE1206
202+
"E1300", # bad-format-character / ruff PLE1300
168203
"E1301", # truncated-format-string / ruff F501
169204
"E1302", # mixed-format-string / ruff F506
170205
"E1303", # format-needs-mapping / ruff F502
171206
"E1304", # missing-format-string-key / ruff F524
207+
"E1305", # too-many-format-args / ruff F522
208+
"E1306", # too-few-format-args / ruff F524
172209
"E1307", # bad-string-format-type / ruff PLE1307
173210
"E1310", # bad-str-strip-call / ruff PLE1310
211+
"E1519", # singledispatch-method / ruff PLE1519
212+
"E1520", # singledispatchmethod-function / ruff PLE1520
213+
"E1700", # yield-inside-async-function / ruff PLE1700
174214
"E2502", # bidirectional-unicode / ruff PLE2502
175215
"E2510", # invalid-character-backspace / ruff PLE2510
176216
"E2512", # invalid-character-sub / ruff PLE2512
177217
"E2513", # invalid-character-esc / ruff PLE2513
178218
"E2514", # invalid-character-nul / ruff PLE2514
179219
"E2515", # invalid-character-zero-width-space / ruff PLE2515
220+
"E4703", # modified-iterating-set / ruff PLE4703
180221
"R0123", # literal-comparison / ruff F632
222+
"R0124", # comparison-with-itself / ruff PLR0124
181223
"R0133", # comparison-of-constants / ruff PLR0133
224+
"R0202", # no-classmethod-decorator / ruff PLR0202
225+
"R0203", # no-staticmethod-decorator / ruff PLR0203
182226
"R0205", # useless-object-inheritance / ruff UP004
227+
"R0206", # property-with-parameters / ruff PLR0206
228+
"R0402", # consider-using-from-import / ruff PLR0402
229+
"R0904", # too-many-public-methods / ruff PLR0904
183230
"R0911", # too-many-return-statements / ruff PLR0911
184231
"R0912", # too-many-branches / ruff PLR0912
232+
"R0913", # too-many-arguments / ruff PLR0913
233+
"R0914", # too-many-locals / ruff PLR0914
185234
"R0915", # too-many-statements / ruff PLR0915
186-
# "R1260", # too-complex / ruff C901
187-
"R1701", # consider-merging-isinstance / ruff PLR1701
188-
"R1706", # consider-using-ternary / ruff SIM108
235+
"R0916", # too-many-boolean-expressions / ruff PLR0916
236+
"R1260", # too-complex / ruff C901
237+
"R1701", # consider-merging-isinstance / ruff SIM101
238+
"R1702", # too-many-nested-blocks / ruff PLR1702
239+
"R1703", # simplifiable-if-statement / ruff SIM108
240+
"R1704", # redefined-argument-from-local / ruff PLR1704
241+
"R1705", # no-else-return / ruff RET505
189242
"R1707", # trailing-comma-tuple / ruff COM818
190243
"R1710", # inconsistent-return-statements / ruff PLR1710
191244
"R1711", # useless-return / ruff PLR1711
245+
"R1714", # consider-using-in / ruff PLR1714
192246
"R1715", # consider-using-get / ruff SIM401
193247
"R1717", # consider-using-dict-comprehension / ruff C402
194248
"R1718", # consider-using-set-comprehension / ruff C401
195-
"R1721", # unnecessary-comprehension / ruff PLR1721
249+
"R1719", # simplifiable-if-expression / ruff PLR1719
250+
"R1720", # no-else-raise / ruff RET506
251+
"R1721", # unnecessary-comprehension / ruff C416
196252
"R1722", # consider-using-sys-exit / ruff PLR1722
253+
"R1723", # no-else-break / ruff RET508
254+
"R1724", # no-else-continue / ruff RET507
197255
"R1725", # super-with-arguments / ruff UP008
198256
"R1728", # consider-using-generator / ruff C417
199-
"R1729", # use-a-generator / ruff C417
257+
"R1729", # use-a-generator / ruff C419
258+
"R1730", # consider-using-min-builtin / ruff PLR1730
259+
"R1731", # consider-using-max-builtin / ruff PLR1730
260+
"R1732", # consider-using-with / ruff SIM115
261+
"R1733", # unnecessary-dict-index-lookup / ruff PLR1733
262+
"R1734", # use-list-literal / ruff C405
200263
"R1734", # use-list-literal / ruff C405
201264
"R1735", # use-dict-literal / ruff C406
202-
# "R2004", # magic-value-comparison / ruff PLR2004
203-
# "R5501", # else-if-used / ruff PLR5501
204-
# "R6002", # consider-using-alias / ruff UP006
205-
# "R6003", # consider-alternative-union-syntax / ruff UP007
265+
"R2004", # magic-value-comparison / ruff PLR2004
266+
"R2044", # empty-comment / ruff PLR2044
267+
"R5501", # else-if-used / ruff PLR5501
268+
"R6002", # consider-using-alias / ruff UP006
269+
"R6003", # consider-alternative-union-syntax / ruff UP007
270+
"R6104", # consider-using-augmented-assign / ruff PLR6104
271+
"R6201", # use-set-for-membership / ruff PLR6201
272+
"R6301", # no-self-use / ruff PLR6301
206273
"W0102", # dangerous-default-value / ruff B006
207274
"W0104", # pointless-statement / ruff B018
208275
"W0106", # expression-not-assigned / ruff B018
276+
"W0107", # unnecessary-pass / ruff PIE790
277+
"W0108", # unnecessary-lambda / ruff PLW0108
209278
"W0109", # duplicate-key / ruff F601
210279
"W0120", # useless-else-on-loop / ruff PLW0120
280+
"W0122", # exec-used / ruff S102
281+
"W0123", # eval-used / ruff S307
282+
"W0127", # self-assigning-variable / ruff PLW0127
211283
"W0129", # assert-on-string-literal / ruff PLW0129
212-
# "W0160", # consider-ternary-expression / ruff SIM108
284+
"W0130", # duplicate-value / ruff B033
285+
"W0131", # named-expr-without-context / ruff PLW0131
286+
"W0133", # pointless-exception-statement / ruff PLW0133
287+
"W0150", # lost-exception / ruff B012
288+
"W0160", # consider-ternary-expression / ruff SIM108
289+
"W0177", # nan-comparison / ruff PLW0177
213290
"W0199", # assert-on-tuple / ruff F631
291+
"W0211", # bad-staticmethod-argument / ruff PLW0211
292+
"W0212", # protected-access / ruff SLF001
293+
"W0245", # super-without-brackets / ruff PLW0245
294+
"W0301", # unnecessary-semicolon / ruff E703
295+
"W0311", # bad-indentation / ruff E111
214296
"W0401", # wildcard-import / ruff F403
297+
"W0404", # reimported / ruff F811
215298
"W0406", # import-self / ruff PLW0406
216299
"W0410", # misplaced-future / ruff F404
300+
"W0511", # fixme / ruff PLW0511
217301
"W0602", # global-variable-not-assigned / ruff PLW0602
218302
"W0603", # global-statement / ruff PLW0603
303+
"W0604", # global-at-module-level / ruff PLW0604
219304
"W0611", # unused-import / ruff F401
220305
"W0612", # unused-variable / ruff F841
221306
"W0613", # unused-argument / ruff ARG001
222307
"W0622", # redefined-builtin / ruff A001
223308
"W0640", # cell-var-from-loop / ruff B023
224309
"W0702", # bare-except / ruff E722
225310
"W0705", # duplicate-except / ruff B014
311+
"W0706", # try-except-raise / ruff TRY302
312+
"W0707", # raise-missing-from / ruff B904
226313
"W0711", # binary-op-exception / ruff PLW0711
227-
"W0718", # broad-exception-caught / ruff PLW0718
228-
"W1300", # bad-format-string-key / ruff PLW1300
314+
"W0718", # broad-exception-caught / ruff BLE001
315+
"W0719", # broad-exception-raised / ruff TRY002
316+
"W1113", # keyword-arg-before-vararg / ruff B026
317+
"W1201", # logging-not-lazy / ruff G002
318+
"W1202", # logging-format-interpolation / ruff G001
319+
"W1203", # logging-fstring-interpolation / ruff G004
229320
"W1301", # unused-format-string-key / ruff F504
230-
"W1302", # bad-format-string / ruff PLW1302
321+
"W1302", # bad-format-string / ruff F521
322+
"W1303", # missing-format-argument-key / ruff F524
231323
"W1304", # unused-format-string-argument / ruff F507
232-
"W1308", # duplicate-string-formatting-argument / ruff PLW1308
324+
"W1305", # format-combined-specification / ruff F525
233325
"W1309", # f-string-without-interpolation / ruff F541
234-
"W1310", # format-string-without-interpolation / ruff PLW1310
326+
"W1310", # format-string-without-interpolation / ruff F541
235327
"W1401", # anomalous-backslash-in-string / ruff W605
328+
"W1404", # implicit-str-concat / ruff ISC001
236329
"W1405", # inconsistent-quotes / ruff Q000
330+
"W1406", # redundant-u-string-prefix / ruff UP025
331+
"W1501", # bad-open-mode / ruff PLW1501
237332
"W1508", # invalid-envvar-default / ruff PLW1508
238-
"W1515" # forgotten-debug-statement / ruff T100
333+
"W1509", # subprocess-popen-preexec-fn / ruff PLW1509
334+
"W1510", # subprocess-run-check / ruff PLW1510
335+
"W1514", # unspecified-encoding / ruff PLW1514
336+
"W1515", # forgotten-debug-statement / ruff T100
337+
"W1518", # method-cache-max-size-none / ruff B019
338+
"W1641", # eq-without-hash / ruff PLW1641
339+
"W2101", # useless-with-lock / ruff PLW2101
340+
"W2301", # unnecessary-ellipsis / ruff PLW2301
341+
"W2402", # non-ascii-file-name / ruff N999
342+
"W2901", # redefined-loop-name / ruff PLW2901
343+
"W3201", # bad-dunder-name / ruff PLW3201
344+
"W3301" # nested-min-max / ruff PLW3301
239345
]
240346
enable = [
241347
"useless-suppression" # Identify unneeded pylint disable statements
@@ -282,10 +388,6 @@ ignore = [
282388
'ARG005', # Unused lambda argument: `args`
283389
'B006', # Do not use mutable data structures for argument defaults
284390
'C901', # `_params_row_for_entry` is too complex (11 > 10)
285-
'D100', # Missing docstring in public module
286-
'D101', # Missing docstring in public class
287-
'D102', # Missing docstring in public method
288-
'D103', # Missing docstring in public function
289391
'FBT001', # Boolean positional arg in function definition
290392
'FBT002', # Boolean default value in function definition
291393
'FBT003', # Boolean positional value in function call
@@ -328,9 +430,10 @@ lines-between-types = 1 # Separate import/from with 1 line
328430
[tool.ruff.lint.per-file-ignores]
329431
"tests/**" = ["SLF001", "S101", "S602"]
330432
"tests/integration/actions/collections/__init__.py" = ["A005"]
433+
"src/ansible_navigator/tm_tokenize/*" = ["D100", "D101", "D102", "D103"]
331434

332435
[tool.ruff.lint.pydocstyle]
333-
convention = "pep257"
436+
convention = "google"
334437

335438
[tool.setuptools.dynamic]
336439
dependencies = {file = [".config/requirements.in"]}

src/ansible_navigator/action_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def initialize_ui(self, refresh: int) -> None:
8080
)
8181

8282
def run(self, _screen: Window) -> None:
83-
# pylint: disable=protected-access
8483
"""Run the app.
8584
8685
Initialize the UI.

src/ansible_navigator/actions/collections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ def _get_collection_plugins_details(
668668
return plugins_details
669669

670670
def _parse_collection_info_stdout(self) -> dict[str, Any]:
671-
# pylint: disable=too-many-nested-blocks
672671
"""Parse collection information from catalog collection cache.
673672
674673
Returns:

src/ansible_navigator/actions/doc.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ def run_stdout(self) -> RunStdoutReturn:
149149
return RunStdoutReturn(message=error, return_code=return_code)
150150

151151
def _run_runner(self) -> dict[Any, Any] | tuple[str, str, int] | None:
152-
# pylint: disable=no-else-return
153152
"""Use the runner subsystem to retrieve the configuration.
154153
155154
Raises:
@@ -214,36 +213,35 @@ def _run_runner(self) -> dict[Any, Any] | tuple[str, str, int] | None:
214213
)
215214
plugin_doc_response = self._extract_plugin_doc(plugin_doc, plugin_doc_err)
216215
return plugin_doc_response
216+
kwargs.update({"host_cwd": str(Path.cwd())})
217+
if self._args.execution_environment:
218+
ansible_doc_path = "ansible-doc"
217219
else:
218-
kwargs.update({"host_cwd": str(Path.cwd())})
219-
if self._args.execution_environment:
220-
ansible_doc_path = "ansible-doc"
221-
else:
222-
exec_path = shutil.which("ansible-doc")
223-
if exec_path is None:
224-
msg = "'ansible-doc' executable not found"
225-
self._logger.error(msg)
226-
raise RuntimeError(msg)
227-
ansible_doc_path = exec_path
220+
exec_path = shutil.which("ansible-doc")
221+
if exec_path is None:
222+
msg = "'ansible-doc' executable not found"
223+
self._logger.error(msg)
224+
raise RuntimeError(msg)
225+
ansible_doc_path = exec_path
228226

229-
pass_through_arg = []
230-
if self._plugin_name is not C.NOT_SET:
231-
pass_through_arg.append(self._plugin_name)
227+
pass_through_arg = []
228+
if self._plugin_name is not C.NOT_SET:
229+
pass_through_arg.append(self._plugin_name)
232230

233-
if self._plugin_type is not C.NOT_SET:
234-
pass_through_arg.extend(["-t", self._plugin_type])
231+
if self._plugin_type is not C.NOT_SET:
232+
pass_through_arg.extend(["-t", self._plugin_type])
235233

236-
if self._args.help_doc is True:
237-
pass_through_arg.append("--help")
234+
if self._args.help_doc is True:
235+
pass_through_arg.append("--help")
238236

239-
if isinstance(self._args.cmdline, list):
240-
pass_through_arg.extend(self._args.cmdline)
237+
if isinstance(self._args.cmdline, list):
238+
pass_through_arg.extend(self._args.cmdline)
241239

242-
kwargs.update({"cmdline": pass_through_arg})
240+
kwargs.update({"cmdline": pass_through_arg})
243241

244-
self._runner = Command(executable_cmd=ansible_doc_path, **kwargs)
245-
stdout_return = self._runner.run()
246-
return stdout_return
242+
self._runner = Command(executable_cmd=ansible_doc_path, **kwargs)
243+
stdout_return = self._runner.run()
244+
return stdout_return
247245

248246
def _extract_plugin_doc(
249247
self,

src/ansible_navigator/actions/inventory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def _build_group_menu(self, key: str | None = None) -> Step:
385385
menu_entry["__taxonomy"] = taxonomy
386386
menu_entry["__type"] = "group"
387387
if hosts:
388-
menu_entry.update({c: "" for c in self._show_columns})
388+
menu_entry.update(dict.fromkeys(self._show_columns, ""))
389389
menu.append(menu_entry)
390390

391391
return Step(

src/ansible_navigator/actions/select.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# noqa: A005
2-
31
"""Menu selection implementation.
42
53
Processor of a menu selection from a numeric key press

0 commit comments

Comments
 (0)