Skip to content

Commit 753a821

Browse files
committed
Apply new rule suffix upgrade
ghstack-source-id: b9458f0 Pull Request resolved: #351
1 parent c381deb commit 753a821

32 files changed

+107
-106
lines changed

docs/guide/builtins.rst

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,35 @@ Built-in Rules
1717

1818
.. automodule:: fixit.rules
1919

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
4949

5050
Discourages use of ``or`` in except clauses. If an except clause needs to catch multiple exceptions,
5151
they must be expressed as a parenthesized tuple, for example:
@@ -124,7 +124,7 @@ Built-in Rules
124124
print()
125125
except ValueError or TypeError:
126126
pass
127-
.. class:: CollapseIsinstanceChecksRule
127+
.. class:: CollapseIsinstanceChecks
128128

129129
The built-in ``isinstance`` function, instead of a single type,
130130
can take a tuple of types and check whether given target suits
@@ -165,7 +165,7 @@ Built-in Rules
165165
# suggested fix
166166
isinstance(x, (y, z, q))
167167
168-
.. class:: ComparePrimitivesByEqualRule
168+
.. class:: ComparePrimitivesByEqual
169169

170170
Enforces the use of ``==`` and ``!=`` in comparisons to primitives rather than ``is`` and ``is not``.
171171
The ``==`` operator checks equality (https://docs.python.org/3/reference/datamodel.html#object.__eq__),
@@ -204,7 +204,7 @@ Built-in Rules
204204
# suggested fix
205205
a == '1'
206206
207-
.. class:: CompareSingletonPrimitivesByIsRule
207+
.. class:: CompareSingletonPrimitivesByIs
208208

209209
Enforces the use of `is` and `is not` in comparisons to singleton primitives (None, True, False) rather than == and !=.
210210
The == operator checks equality, when in this scenario, we want to check identity.
@@ -243,7 +243,7 @@ Built-in Rules
243243
# suggested fix
244244
x is not False
245245
246-
.. class:: DeprecatedUnittestAssertsRule
246+
.. class:: DeprecatedUnittestAsserts
247247

248248
Discourages the use of various deprecated unittest.TestCase functions
249249

@@ -282,7 +282,7 @@ Built-in Rules
282282
# suggested fix
283283
self.assertNotEqual(a, b)
284284
285-
.. class:: ExplicitFrozenDataclassRule
285+
.. class:: ExplicitFrozenDataclass
286286

287287
Encourages the use of frozen dataclass objects by telling users to specify the
288288
kwarg.
@@ -338,7 +338,7 @@ Built-in Rules
338338
@dataclass(frozen=True) # called as a function, no kwargs
339339
class Cls: pass
340340
341-
.. class:: NoAssertTrueForComparisonsRule
341+
.. class:: NoAssertTrueForComparisons
342342

343343
Finds incorrect use of ``assertTrue`` when the intention is to compare two values.
344344
These calls are replaced with ``assertEqual``.
@@ -378,7 +378,7 @@ Built-in Rules
378378
# suggested fix
379379
self.assertEqual(hash(s[:4]), 0x1234)
380380
381-
.. class:: NoInheritFromObjectRule
381+
.. class:: NoInheritFromObject
382382

383383
In Python 3, a class is inherited from ``object`` by default.
384384
Explicitly inheriting from ``object`` is redundant, so removing it keeps the code simpler.
@@ -421,7 +421,7 @@ Built-in Rules
421421
class B(A):
422422
pass
423423
424-
.. class:: NoNamedTupleRule
424+
.. class:: NoNamedTuple
425425

426426
Enforce the use of ``dataclasses.dataclass`` decorator instead of ``NamedTuple`` for cleaner customization and
427427
inheritance. It supports default value, combining fields for inheritance, and omitting optional fields at
@@ -479,7 +479,7 @@ Built-in Rules
479479
class Foo:
480480
pass
481481
482-
.. class:: NoRedundantArgumentsSuperRule
482+
.. class:: NoRedundantArgumentsSuper
483483

484484
Remove redundant arguments when using super for readability.
485485

@@ -530,7 +530,7 @@ Built-in Rules
530530
def foo(cls, bar):
531531
super().foo(bar)
532532
533-
.. class:: NoRedundantFStringRule
533+
.. class:: NoRedundantFString
534534

535535
Remove redundant f-string without placeholders.
536536

@@ -567,7 +567,7 @@ Built-in Rules
567567
# suggested fix
568568
bad: str = 'bad'
569569
570-
.. class:: NoRedundantLambdaRule
570+
.. class:: NoRedundantLambda
571571

572572
A lamba function which has a single objective of
573573
passing all it is arguments to another callable can
@@ -602,7 +602,7 @@ Built-in Rules
602602
# suggested fix
603603
foo
604604
605-
.. class:: NoRedundantListComprehensionRule
605+
.. class:: NoRedundantListComprehension
606606

607607
A derivative of flake8-comprehensions's C407 rule.
608608

@@ -635,7 +635,7 @@ Built-in Rules
635635
# suggested fix
636636
all(val for val in iterable)
637637
638-
.. class:: NoStaticIfConditionRule
638+
.. class:: NoStaticIfCondition
639639

640640
Discourages ``if`` conditions which evaluate to a static value (e.g. ``or True``, ``and False``, etc).
641641

@@ -665,7 +665,7 @@ Built-in Rules
665665
666666
if crazy_expression or True:
667667
do_something()
668-
.. class:: NoStringTypeAnnotationRule
668+
.. class:: NoStringTypeAnnotation
669669

670670
Enforce the use of type identifier instead of using string type hints for simplicity and better syntax highlighting.
671671
Starting in Python 3.7, ``from __future__ import annotations`` can postpone evaluation of type annotations
@@ -732,7 +732,7 @@ Built-in Rules
732732
async def foo() -> Class:
733733
return await Class()
734734
735-
.. class:: ReplaceUnionWithOptionalRule
735+
.. class:: ReplaceUnionWithOptional
736736

737737
Enforces the use of ``Optional[T]`` over ``Union[T, None]`` and ``Union[None, T]``.
738738
See https://docs.python.org/3/library/typing.html#typing.Optional to learn more about Optionals.
@@ -773,7 +773,7 @@ Built-in Rules
773773
def func() -> Optional[Dict[str, int]]:
774774
pass
775775
776-
.. class:: RewriteToComprehensionRule
776+
.. class:: RewriteToComprehension
777777

778778
A derivative of flake8-comprehensions's C400-C402 and C403-C404.
779779
Comprehensions are more efficient than functions calls. This C400-C402
@@ -811,7 +811,7 @@ Built-in Rules
811811
# suggested fix
812812
[val for row in matrix for val in row]
813813
814-
.. class:: RewriteToLiteralRule
814+
.. class:: RewriteToLiteral
815815

816816
A derivative of flake8-comprehensions' C405-C406 and C409-C410. It's
817817
unnecessary to use a list or tuple literal within a call to tuple, list,
@@ -846,7 +846,7 @@ Built-in Rules
846846
# suggested fix
847847
(1, 2)
848848
849-
.. class:: SortedAttributesRule
849+
.. class:: SortedAttributes
850850

851851
Ever wanted to sort a bunch of class attributes alphabetically?
852852
Well now it's easy! Just add "@sorted-attributes" in the doc string of
@@ -910,7 +910,7 @@ Built-in Rules
910910
def get_foo(cls) -> str:
911911
return "some random thing"
912912
913-
.. class:: UseAssertInRule
913+
.. class:: UseAssertIn
914914

915915
Discourages use of ``assertTrue(x in y)`` and ``assertFalse(x in y)``
916916
as it is deprecated (https://docs.python.org/3.8/library/unittest.html#deprecated-aliases).
@@ -950,7 +950,7 @@ Built-in Rules
950950
# suggested fix
951951
self.assertIn(f(), b)
952952
953-
.. class:: UseAssertIsNotNoneRule
953+
.. class:: UseAssertIsNotNone
954954

955955
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).
956956
Use ``assertIsNotNone(x)`` and ``assertIsNone(x)``) instead.
@@ -989,7 +989,7 @@ Built-in Rules
989989
# suggested fix
990990
self.assertIsNotNone(x)
991991
992-
.. class:: UseAsyncSleepInAsyncDefRule
992+
.. class:: UseAsyncSleepInAsyncDef
993993

994994
Detect if asyncio.sleep is used in an async function
995995

@@ -1023,7 +1023,7 @@ Built-in Rules
10231023
from time import sleep
10241024
async def func():
10251025
sleep(1)
1026-
.. class:: UseClassNameAsCodeRule
1026+
.. class:: UseClassNameAsCode
10271027

10281028
Meta lint rule which checks that codes of lint rules are migrated to new format in lint rule class definitions.
10291029

@@ -1075,7 +1075,7 @@ Built-in Rules
10751075
)
10761076
]
10771077
1078-
.. class:: UseClsInClassmethodRule
1078+
.. class:: UseClsInClassmethod
10791079

10801080
Enforces using ``cls`` as the first argument in a ``@classmethod``.
10811081

@@ -1135,7 +1135,7 @@ Built-in Rules
11351135
def cm(cls):
11361136
return cls
11371137
1138-
.. class:: UseFstringRule
1138+
.. class:: UseFstring
11391139

11401140
Encourages the use of f-string instead of %-formatting or .format() for high code quality and efficiency.
11411141

@@ -1184,7 +1184,7 @@ Built-in Rules
11841184
# suggested fix
11851185
f"{'hi'}"
11861186
1187-
.. class:: UseLintFixmeCommentRule
1187+
.. class:: UseLintFixmeComment
11881188

11891189
To silence a lint warning, use ``lint-fixme`` (when plans to fix the issue later) or ``lint-ignore``
11901190
(when the lint warning is not valid) comments.
@@ -1222,7 +1222,7 @@ Built-in Rules
12221222
1,
12231223
2, # noqa
12241224
)
1225-
.. class:: UseTypesFromTypingRule
1225+
.. class:: UseTypesFromTyping
12261226

12271227
Enforces the use of types from the ``typing`` module in type annotations in place
12281228
of ``builtins.{builtin_type}`` since the type system doesn't recognize the latter

examples/noop.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
from fixit import LintRule
77

8-
class NoOpRule(LintRule):
8+
9+
class NoOp(LintRule):
910
MESSAGE = "You shouldn't be seeing this"
1011
VALID = []
1112
INVALID = []

examples/teambread/rules/hollywood.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from fixit import Invalid, LintRule, Valid
88

99

10-
class HollywoodNameRule(LintRule):
10+
class HollywoodName(LintRule):
1111
# clean code samples
1212
VALID = [
1313
Valid('name = "Susan"'),

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ build = [
114114
enable = ["fixit.rules"]
115115
disable = [
116116
# We don't want everything to be frozen or have to set frozen=False
117-
"fixit.rules:ExplicitFrozenDataclassRule",
117+
"fixit.rules:ExplicitFrozenDataclass",
118118
# We need noqa for compat with flake8 until we jettison flake8
119-
"fixit.rules:UseLintFixmeCommentRule",
119+
"fixit.rules:UseLintFixmeComment",
120120
]
121121
python-version = "3.10"
122122
formatter = "ufmt"

src/fixit/rules/avoid_or_in_except.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from fixit import Invalid, LintRule, Valid
1010

1111

12-
class AvoidOrInExceptRule(LintRule):
12+
class AvoidOrInExcept(LintRule):
1313
"""
1414
Discourages use of ``or`` in except clauses. If an except clause needs to catch multiple exceptions,
1515
they must be expressed as a parenthesized tuple, for example:

src/fixit/rules/chained_instance_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818

1919

20-
class CollapseIsinstanceChecksRule(LintRule):
20+
class CollapseIsinstanceChecks(LintRule):
2121
"""
2222
The built-in ``isinstance`` function, instead of a single type,
2323
can take a tuple of types and check whether given target suits

src/fixit/rules/cls_in_classmethod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def leave_Name(self, original_node: cst.Name, updated_node: cst.Name) -> cst.Nam
3737
return updated_node
3838

3939

40-
class UseClsInClassmethodRule(LintRule):
40+
class UseClsInClassmethod(LintRule):
4141
"""
4242
Enforces using ``cls`` as the first argument in a ``@classmethod``.
4343
"""

src/fixit/rules/compare_primitives_by_equal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from fixit import Invalid, LintRule, Valid
99

1010

11-
class ComparePrimitivesByEqualRule(LintRule):
11+
class ComparePrimitivesByEqual(LintRule):
1212
"""
1313
Enforces the use of ``==`` and ``!=`` in comparisons to primitives rather than ``is`` and ``is not``.
1414
The ``==`` operator checks equality (https://docs.python.org/3/reference/datamodel.html#object.__eq__),

src/fixit/rules/compare_singleton_primitives_by_is.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from fixit import Invalid, LintRule, Valid
1212

1313

14-
class CompareSingletonPrimitivesByIsRule(LintRule):
14+
class CompareSingletonPrimitivesByIs(LintRule):
1515
"""
1616
Enforces the use of `is` and `is not` in comparisons to singleton primitives (None, True, False) rather than == and !=.
1717
The == operator checks equality, when in this scenario, we want to check identity.

src/fixit/rules/deprecated_unittest_asserts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from fixit import Invalid, LintRule, Valid
1010

1111

12-
class DeprecatedUnittestAssertsRule(LintRule):
12+
class DeprecatedUnittestAsserts(LintRule):
1313
"""
1414
Discourages the use of various deprecated unittest.TestCase functions
1515

src/fixit/rules/explicit_frozen_dataclass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from fixit import CodePosition, CodeRange, Invalid, LintRule, Valid
1212

1313

14-
class ExplicitFrozenDataclassRule(LintRule):
14+
class ExplicitFrozenDataclass(LintRule):
1515
"""
1616
Encourages the use of frozen dataclass objects by telling users to specify the
1717
kwarg.

0 commit comments

Comments
 (0)