Skip to content

Commit 23dd754

Browse files
danieleadesdaniel.eadespicnixz
authored
[lint] ruff simplify config (#12086)
Co-authored-by: daniel.eades <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
1 parent c86e908 commit 23dd754

File tree

1 file changed

+10
-83
lines changed

1 file changed

+10
-83
lines changed

.ruff.toml

Lines changed: 10 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ ignore = [
2323
"F841", # Local variable `{name}` is assigned to but never used
2424
# pylint
2525
"PLC1901", # simplify truthy/falsey string comparisons
26+
"SIM102", # Use a single `if` statement instead of nested `if` statements
27+
"SIM108", # Use ternary operator `{contents}` instead of `if`-`else`-block
28+
"UP031", # Use format specifiers instead of percent format
29+
"UP032", # Use f-string instead of `format` call
30+
2631
]
2732
external = [ # Whitelist for RUF100 unknown code warnings
2833
"E704",
@@ -152,10 +157,7 @@ select = [
152157
"G202", # Logging statement has redundant `exc_info`
153158
# isort ('I')
154159
"I",
155-
# flake8-import-conventions ('ICN')
156-
"ICN001", # `{name}` should be imported as `{asname}`
157-
"ICN002", # `{name}` should not be imported as `{asname}`
158-
"ICN003", # Members of `{name}` should not be imported explicitly
160+
"ICN", # flake8-import-conventions
159161
# flake8-no-pep420 ('INP')
160162
"INP",
161163
# flake8-gettext ('INT')
@@ -346,52 +348,16 @@ select = [
346348
"S612", # Use of insecure `logging.config.listen` detected
347349
# "S701", # Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
348350
# "S702", # Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks
349-
# flake8-simplify ('SIM')
350-
"SIM101", # Multiple `isinstance` calls for `{name}`, merge into a single call
351-
# "SIM102", # Use a single `if` statement instead of nested `if` statements
352-
# "SIM103", # Return the condition `{condition}` directly
353-
"SIM105", # Use `contextlib.suppress({exception})` instead of `try`-`except`-`pass`
354-
"SIM107", # Don't use `return` in `try`-`except` and `finally`
355-
# "SIM108", # Use ternary operator `{contents}` instead of `if`-`else`-block
356-
"SIM109", # Use `{replacement}` instead of multiple equality comparisons
357-
"SIM110", # Use `{replacement}` instead of `for` loop
358-
"SIM112", # Use capitalized environment variable `{expected}` instead of `{original}`
359-
"SIM114", # Combine `if` branches using logical `or` operator
360-
"SIM115", # Use context handler for opening files
361-
"SIM116", # Use a dictionary instead of consecutive `if` statements
362-
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
363-
"SIM118", # Use `{key} {operator} {dict}` instead of `{key} {operator} {dict}.keys()`
364-
"SIM201", # Use `{left} != {right}` instead of `not {left} == {right}`
365-
"SIM202", # Use `{left} == {right}` instead of `not {left} != {right}`
366-
"SIM208", # Use `{expr}` instead of `not (not {expr})`
367-
"SIM210", # Use `bool({expr})` instead of `True if {expr} else False`
368-
"SIM211", # Use `not {expr}` instead of `False if {expr} else True`
369-
"SIM212", # Use `{expr_else} if {expr_else} else {expr_body}` instead of `{expr_body} if not {expr_else} else {expr_else}`
370-
"SIM220", # Use `False` instead of `{name} and not {name}`
371-
"SIM221", # Use `True` instead of `{name} or not {name}`
372-
"SIM222", # Use `{expr}` instead of `{replaced}`
373-
"SIM223", # Use `{expr}` instead of `{replaced}`
374-
"SIM300", # Yoda conditions are discouraged, use `{suggestion}` instead
375-
"SIM401", # Use `{contents}` instead of an `if` block
376-
"SIM910", # Use `{expected}` instead of `{original}`
351+
"SIM", # flake8-simplify
377352
# flake8-self ('SLF')
378353
# NOT YET USED
379-
# flake8-slots ('SLOT')
380-
"SLOT000", # Subclasses of `str` should define `__slots__`
381-
"SLOT001", # Subclasses of `tuple` should define `__slots__`
382-
"SLOT002", # Subclasses of `collections.namedtuple()` should define `__slots__`
354+
"SLOT", # flake8-slots
383355
# flake8-debugger ('T10')
384356
"T100", # Trace found: `{name}` used
385357
# flake8-print ('T20')
386358
"T201", # `print` found
387359
"T203", # `pprint` found
388-
# flake8-type-checking ('TCH')
389-
"TCH001", # Move application import `{}` into a type-checking block
390-
"TCH002", # Move third-party import `{}` into a type-checking block
391-
"TCH003", # Move standard library import `{}` into a type-checking block
392-
"TCH004", # Move import `{qualified_name}` out of type-checking block. Import is used for more than type hinting.
393-
"TCH005", # Found empty type-checking block
394-
"TCH010", # Invalid string member in `X | Y`-style union type
360+
"TCH", # flake8-type-checking
395361
# flake8-todos ('TD')
396362
# "TD001", # Invalid TODO tag: `{tag}`
397363
# "TD003", # Missing issue link on the line following this TODO
@@ -407,46 +373,7 @@ select = [
407373
# Trio is not used in Sphinx
408374
# tryceratops ('TRY')
409375
# NOT YET USED
410-
# pyupgrade ('UP')
411-
"UP001", # `__metaclass__ = type` is implied
412-
"UP003", # Use `{}` instead of `type(...)`
413-
"UP004", # Class `{name}` inherits from `object`
414-
"UP005", # `{alias}` is deprecated, use `{target}`
415-
"UP006", # Use `{to}` instead of `{from}` for type annotation
416-
"UP007", # Use `X | Y` for type annotations
417-
"UP008", # Use `super()` instead of `super(__class__, self)`
418-
"UP009", # UTF-8 encoding declaration is unnecessary
419-
"UP010", # Unnecessary `__future__` import `{import}` for target Python version
420-
"UP011", # Unnecessary parentheses to `functools.lru_cache`
421-
"UP012", # Unnecessary call to `encode` as UTF-8
422-
"UP013", # Convert `{name}` from `TypedDict` functional to class syntax
423-
"UP014", # Convert `{name}` from `NamedTuple` functional to class syntax
424-
"UP015", # Unnecessary open mode parameters
425-
"UP017", # Use `datetime.UTC` alias
426-
"UP018", # Unnecessary `{literal_type}` call (rewrite as a literal)
427-
"UP019", # `typing.Text` is deprecated, use `str`
428-
"UP020", # Use builtin `open`
429-
"UP021", # `universal_newlines` is deprecated, use `text`
430-
"UP022", # Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output`
431-
"UP023", # `cElementTree` is deprecated, use `ElementTree`
432-
"UP024", # Replace aliased errors with `OSError`
433-
"UP025", # Remove unicode literals from strings
434-
"UP026", # `mock` is deprecated, use `unittest.mock`
435-
"UP027", # Replace unpacked list comprehension with a generator expression
436-
"UP028", # Replace `yield` over `for` loop with `yield from`
437-
"UP029", # Unnecessary builtin import: `{import}`
438-
"UP030", # Use implicit references for positional format fields
439-
# "UP031", # Use format specifiers instead of percent format
440-
# "UP032", # Use f-string instead of `format` call
441-
"UP033", # Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`
442-
"UP034", # Avoid extraneous parentheses
443-
"UP035", # Import from `{target}` instead: {names}
444-
"UP036", # Version block is outdated for minimum Python version
445-
"UP037", # Remove quotes from type annotation
446-
"UP038", # Use `X | Y` in `{}` call instead of `(X, Y)`
447-
"UP039", # Unnecessary parentheses after class definition
448-
"UP040", # Type alias `{name}` uses `TypeAlias` annotation instead of the `type` keyword
449-
"UP041", # Replace aliased errors with `TimeoutError`
376+
"UP001", # pyupgrade
450377
# pycodestyle ('W')
451378
"W191", # Indentation contains tabs
452379
# "W291", # Trailing whitespace

0 commit comments

Comments
 (0)