You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/builtins.rst
+55-55Lines changed: 55 additions & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -17,35 +17,35 @@ Built-in Rules
17
17
18
18
.. automodule:: fixit.rules
19
19
20
-
- :class:`AvoidOrInExceptRule`
21
-
- :class:`CollapseIsinstanceChecksRule`
22
-
- :class:`ComparePrimitivesByEqualRule`
23
-
- :class:`CompareSingletonPrimitivesByIsRule`
24
-
- :class:`DeprecatedUnittestAssertsRule`
25
-
- :class:`ExplicitFrozenDataclassRule`
26
-
- :class:`NoAssertTrueForComparisonsRule`
27
-
- :class:`NoInheritFromObjectRule`
28
-
- :class:`NoNamedTupleRule`
29
-
- :class:`NoRedundantArgumentsSuperRule`
30
-
- :class:`NoRedundantFStringRule`
31
-
- :class:`NoRedundantLambdaRule`
32
-
- :class:`NoRedundantListComprehensionRule`
33
-
- :class:`NoStaticIfConditionRule`
34
-
- :class:`NoStringTypeAnnotationRule`
35
-
- :class:`ReplaceUnionWithOptionalRule`
36
-
- :class:`RewriteToComprehensionRule`
37
-
- :class:`RewriteToLiteralRule`
38
-
- :class:`SortedAttributesRule`
39
-
- :class:`UseAssertInRule`
40
-
- :class:`UseAssertIsNotNoneRule`
41
-
- :class:`UseAsyncSleepInAsyncDefRule`
42
-
- :class:`UseClassNameAsCodeRule`
43
-
- :class:`UseClsInClassmethodRule`
44
-
- :class:`UseFstringRule`
45
-
- :class:`UseLintFixmeCommentRule`
46
-
- :class:`UseTypesFromTypingRule`
47
-
48
-
.. class:: AvoidOrInExceptRule
20
+
- :class:`AvoidOrInExcept`
21
+
- :class:`CollapseIsinstanceChecks`
22
+
- :class:`ComparePrimitivesByEqual`
23
+
- :class:`CompareSingletonPrimitivesByIs`
24
+
- :class:`DeprecatedUnittestAsserts`
25
+
- :class:`ExplicitFrozenDataclass`
26
+
- :class:`NoAssertTrueForComparisons`
27
+
- :class:`NoInheritFromObject`
28
+
- :class:`NoNamedTuple`
29
+
- :class:`NoRedundantArgumentsSuper`
30
+
- :class:`NoRedundantFString`
31
+
- :class:`NoRedundantLambda`
32
+
- :class:`NoRedundantListComprehension`
33
+
- :class:`NoStaticIfCondition`
34
+
- :class:`NoStringTypeAnnotation`
35
+
- :class:`ReplaceUnionWithOptional`
36
+
- :class:`RewriteToComprehension`
37
+
- :class:`RewriteToLiteral`
38
+
- :class:`SortedAttributes`
39
+
- :class:`UseAssertIn`
40
+
- :class:`UseAssertIsNotNone`
41
+
- :class:`UseAsyncSleepInAsyncDef`
42
+
- :class:`UseClassNameAsCode`
43
+
- :class:`UseClsInClassmethod`
44
+
- :class:`UseFstring`
45
+
- :class:`UseLintFixmeComment`
46
+
- :class:`UseTypesFromTyping`
47
+
48
+
.. class:: AvoidOrInExcept
49
49
50
50
Discourages use of ``or`` in except clauses. If an except clause needs to catch multiple exceptions,
51
51
they must be expressed as a parenthesized tuple, for example:
@@ -124,7 +124,7 @@ Built-in Rules
124
124
print()
125
125
exceptValueErrororTypeError:
126
126
pass
127
-
.. class:: CollapseIsinstanceChecksRule
127
+
.. class:: CollapseIsinstanceChecks
128
128
129
129
The built-in ``isinstance`` function, instead of a single type,
130
130
can take a tuple of types and check whether given target suits
@@ -165,7 +165,7 @@ Built-in Rules
165
165
# suggested fix
166
166
isinstance(x, (y, z, q))
167
167
168
-
.. class:: ComparePrimitivesByEqualRule
168
+
.. class:: ComparePrimitivesByEqual
169
169
170
170
Enforces the use of ``==`` and ``!=`` in comparisons to primitives rather than ``is`` and ``is not``.
171
171
The ``==`` operator checks equality (https://docs.python.org/3/reference/datamodel.html#object.__eq__),
@@ -204,7 +204,7 @@ Built-in Rules
204
204
# suggested fix
205
205
a =='1'
206
206
207
-
.. class:: CompareSingletonPrimitivesByIsRule
207
+
.. class:: CompareSingletonPrimitivesByIs
208
208
209
209
Enforces the use of `is` and `is not` in comparisons to singleton primitives (None, True, False) rather than == and !=.
210
210
The == operator checks equality, when in this scenario, we want to check identity.
@@ -243,7 +243,7 @@ Built-in Rules
243
243
# suggested fix
244
244
x isnotFalse
245
245
246
-
.. class:: DeprecatedUnittestAssertsRule
246
+
.. class:: DeprecatedUnittestAsserts
247
247
248
248
Discourages the use of various deprecated unittest.TestCase functions
249
249
@@ -282,7 +282,7 @@ Built-in Rules
282
282
# suggested fix
283
283
self.assertNotEqual(a, b)
284
284
285
-
.. class:: ExplicitFrozenDataclassRule
285
+
.. class:: ExplicitFrozenDataclass
286
286
287
287
Encourages the use of frozen dataclass objects by telling users to specify the
288
288
kwarg.
@@ -338,7 +338,7 @@ Built-in Rules
338
338
@dataclass(frozen=True) # called as a function, no kwargs
339
339
classCls: pass
340
340
341
-
.. class:: NoAssertTrueForComparisonsRule
341
+
.. class:: NoAssertTrueForComparisons
342
342
343
343
Finds incorrect use of ``assertTrue`` when the intention is to compare two values.
344
344
These calls are replaced with ``assertEqual``.
@@ -378,7 +378,7 @@ Built-in Rules
378
378
# suggested fix
379
379
self.assertEqual(hash(s[:4]), 0x1234)
380
380
381
-
.. class:: NoInheritFromObjectRule
381
+
.. class:: NoInheritFromObject
382
382
383
383
In Python 3, a class is inherited from ``object`` by default.
384
384
Explicitly inheriting from ``object`` is redundant, so removing it keeps the code simpler.
@@ -421,7 +421,7 @@ Built-in Rules
421
421
classB(A):
422
422
pass
423
423
424
-
.. class:: NoNamedTupleRule
424
+
.. class:: NoNamedTuple
425
425
426
426
Enforce the use of ``dataclasses.dataclass`` decorator instead of ``NamedTuple`` for cleaner customization and
427
427
inheritance. It supports default value, combining fields for inheritance, and omitting optional fields at
@@ -479,7 +479,7 @@ Built-in Rules
479
479
classFoo:
480
480
pass
481
481
482
-
.. class:: NoRedundantArgumentsSuperRule
482
+
.. class:: NoRedundantArgumentsSuper
483
483
484
484
Remove redundant arguments when using super for readability.
485
485
@@ -530,7 +530,7 @@ Built-in Rules
530
530
deffoo(cls, bar):
531
531
super().foo(bar)
532
532
533
-
.. class:: NoRedundantFStringRule
533
+
.. class:: NoRedundantFString
534
534
535
535
Remove redundant f-string without placeholders.
536
536
@@ -567,7 +567,7 @@ Built-in Rules
567
567
# suggested fix
568
568
bad: str='bad'
569
569
570
-
.. class:: NoRedundantLambdaRule
570
+
.. class:: NoRedundantLambda
571
571
572
572
A lamba function which has a single objective of
573
573
passing all it is arguments to another callable can
@@ -602,7 +602,7 @@ Built-in Rules
602
602
# suggested fix
603
603
foo
604
604
605
-
.. class:: NoRedundantListComprehensionRule
605
+
.. class:: NoRedundantListComprehension
606
606
607
607
A derivative of flake8-comprehensions's C407 rule.
608
608
@@ -635,7 +635,7 @@ Built-in Rules
635
635
# suggested fix
636
636
all(val for val in iterable)
637
637
638
-
.. class:: NoStaticIfConditionRule
638
+
.. class:: NoStaticIfCondition
639
639
640
640
Discourages ``if`` conditions which evaluate to a static value (e.g. ``or True``, ``and False``, etc).
641
641
@@ -665,7 +665,7 @@ Built-in Rules
665
665
666
666
if crazy_expression orTrue:
667
667
do_something()
668
-
.. class:: NoStringTypeAnnotationRule
668
+
.. class:: NoStringTypeAnnotation
669
669
670
670
Enforce the use of type identifier instead of using string type hints for simplicity and better syntax highlighting.
671
671
Starting in Python 3.7, ``from __future__ import annotations`` can postpone evaluation of type annotations
@@ -732,7 +732,7 @@ Built-in Rules
732
732
asyncdeffoo() -> Class:
733
733
returnawait Class()
734
734
735
-
.. class:: ReplaceUnionWithOptionalRule
735
+
.. class:: ReplaceUnionWithOptional
736
736
737
737
Enforces the use of ``Optional[T]`` over ``Union[T, None]`` and ``Union[None, T]``.
738
738
See https://docs.python.org/3/library/typing.html#typing.Optional to learn more about Optionals.
@@ -773,7 +773,7 @@ Built-in Rules
773
773
deffunc() -> Optional[Dict[str, int]]:
774
774
pass
775
775
776
-
.. class:: RewriteToComprehensionRule
776
+
.. class:: RewriteToComprehension
777
777
778
778
A derivative of flake8-comprehensions's C400-C402 and C403-C404.
779
779
Comprehensions are more efficient than functions calls. This C400-C402
@@ -811,7 +811,7 @@ Built-in Rules
811
811
# suggested fix
812
812
[val for row in matrix for val in row]
813
813
814
-
.. class:: RewriteToLiteralRule
814
+
.. class:: RewriteToLiteral
815
815
816
816
A derivative of flake8-comprehensions' C405-C406 and C409-C410. It's
817
817
unnecessary to use a list or tuple literal within a call to tuple, list,
@@ -846,7 +846,7 @@ Built-in Rules
846
846
# suggested fix
847
847
(1, 2)
848
848
849
-
.. class:: SortedAttributesRule
849
+
.. class:: SortedAttributes
850
850
851
851
Ever wanted to sort a bunch of class attributes alphabetically?
852
852
Well now it's easy! Just add "@sorted-attributes" in the doc string of
@@ -910,7 +910,7 @@ Built-in Rules
910
910
defget_foo(cls) -> str:
911
911
return"some random thing"
912
912
913
-
.. class:: UseAssertInRule
913
+
.. class:: UseAssertIn
914
914
915
915
Discourages use of ``assertTrue(x in y)`` and ``assertFalse(x in y)``
916
916
as it is deprecated (https://docs.python.org/3.8/library/unittest.html#deprecated-aliases).
@@ -950,7 +950,7 @@ Built-in Rules
950
950
# suggested fix
951
951
self.assertIn(f(), b)
952
952
953
-
.. class:: UseAssertIsNotNoneRule
953
+
.. class:: UseAssertIsNotNone
954
954
955
955
Discourages use of ``assertTrue(x is not None)`` and ``assertFalse(x is not None)`` as it is deprecated (https://docs.python.org/3.8/library/unittest.html#deprecated-aliases).
956
956
Use ``assertIsNotNone(x)`` and ``assertIsNone(x)``) instead.
@@ -989,7 +989,7 @@ Built-in Rules
989
989
# suggested fix
990
990
self.assertIsNotNone(x)
991
991
992
-
.. class:: UseAsyncSleepInAsyncDefRule
992
+
.. class:: UseAsyncSleepInAsyncDef
993
993
994
994
Detect if asyncio.sleep is used in an async function
995
995
@@ -1023,7 +1023,7 @@ Built-in Rules
1023
1023
from time import sleep
1024
1024
asyncdeffunc():
1025
1025
sleep(1)
1026
-
.. class:: UseClassNameAsCodeRule
1026
+
.. class:: UseClassNameAsCode
1027
1027
1028
1028
Meta lint rule which checks that codes of lint rules are migrated to new format in lint rule class definitions.
1029
1029
@@ -1075,7 +1075,7 @@ Built-in Rules
1075
1075
)
1076
1076
]
1077
1077
1078
-
.. class:: UseClsInClassmethodRule
1078
+
.. class:: UseClsInClassmethod
1079
1079
1080
1080
Enforces using ``cls`` as the first argument in a ``@classmethod``.
1081
1081
@@ -1135,7 +1135,7 @@ Built-in Rules
1135
1135
defcm(cls):
1136
1136
returncls
1137
1137
1138
-
.. class:: UseFstringRule
1138
+
.. class:: UseFstring
1139
1139
1140
1140
Encourages the use of f-string instead of %-formatting or .format() for high code quality and efficiency.
1141
1141
@@ -1184,7 +1184,7 @@ Built-in Rules
1184
1184
# suggested fix
1185
1185
f"{'hi'}"
1186
1186
1187
-
.. class:: UseLintFixmeCommentRule
1187
+
.. class:: UseLintFixmeComment
1188
1188
1189
1189
To silence a lint warning, use ``lint-fixme`` (when plans to fix the issue later) or ``lint-ignore``
1190
1190
(when the lint warning is not valid) comments.
@@ -1222,7 +1222,7 @@ Built-in Rules
1222
1222
1,
1223
1223
2, # noqa
1224
1224
)
1225
-
.. class:: UseTypesFromTypingRule
1225
+
.. class:: UseTypesFromTyping
1226
1226
1227
1227
Enforces the use of types from the ``typing`` module in type annotations in place
1228
1228
of ``builtins.{builtin_type}`` since the type system doesn't recognize the latter
0 commit comments