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
Encourages the use of frozen dataclass objects by telling users to specify the
288
-
kwarg.
289
-
290
-
Without this lint rule, most users of dataclass won't know to use the kwarg, and
291
-
may unintentionally end up with mutable objects.
292
-
293
-
.. attribute:: MESSAGE
294
-
295
-
When using dataclasses, explicitly specify a frozen keyword argument. Example: `@dataclass(frozen=True)` or `@dataclass(frozen=False)`. Docs: https://docs.python.org/3/library/dataclasses.html
296
-
297
-
.. attribute:: AUTOFIX
298
-
:type: Yes
299
-
300
-
301
-
.. attribute:: VALID
302
-
303
-
.. code:: python
304
-
305
-
@some_other_decorator
306
-
classCls: pass
307
-
.. code:: python
308
-
309
-
from dataclasses import dataclass
310
-
@dataclass(frozen=False)
311
-
classCls: pass
312
-
313
-
.. attribute:: INVALID
314
-
315
-
.. code:: python
316
-
317
-
from dataclasses import dataclass
318
-
@some_unrelated_decorator
319
-
@dataclass# not called as a function
320
-
@another_unrelated_decorator
321
-
classCls: pass
322
-
323
-
# suggested fix
324
-
from dataclasses import dataclass
325
-
@some_unrelated_decorator
326
-
@dataclass(frozen=True) # not called as a function
327
-
@another_unrelated_decorator
328
-
classCls: pass
329
-
330
-
.. code:: python
331
-
332
-
from dataclasses import dataclass
333
-
@dataclass() # called as a function, no kwargs
334
-
classCls: pass
335
-
336
-
# suggested fix
337
-
from dataclasses import dataclass
338
-
@dataclass(frozen=True) # called as a function, no kwargs
339
-
classCls: pass
340
-
341
283
.. class:: NoAssertTrueForComparisons
342
284
343
285
Finds incorrect use of ``assertTrue`` when the intention is to compare two values.
@@ -1023,58 +965,6 @@ Built-in Rules
1023
965
from time import sleep
1024
966
asyncdeffunc():
1025
967
sleep(1)
1026
-
.. class:: UseClassNameAsCode
1027
-
1028
-
Meta lint rule which checks that codes of lint rules are migrated to new format in lint rule class definitions.
1029
-
1030
-
.. attribute:: MESSAGE
1031
-
1032
-
`IG`-series codes are deprecated. Use class name as code instead.
1033
-
1034
-
.. attribute:: AUTOFIX
1035
-
:type: Yes
1036
-
1037
-
1038
-
.. attribute:: VALID
1039
-
1040
-
.. code:: python
1041
-
1042
-
MESSAGE="This is a message"
1043
-
.. code:: python
1044
-
1045
-
from fixit.common.base import CstLintRule
1046
-
classFakeRule(CstLintRule):
1047
-
MESSAGE="This is a message"
1048
-
1049
-
.. attribute:: INVALID
1050
-
1051
-
.. code:: python
1052
-
1053
-
MESSAGE="IG90000 Message"
1054
-
1055
-
# suggested fix
1056
-
MESSAGE="Message"
1057
-
1058
-
.. code:: python
1059
-
1060
-
from fixit.common.base import CstLintRule
1061
-
classFakeRule(CstLintRule):
1062
-
INVALID= [
1063
-
Invalid(
1064
-
code="",
1065
-
kind="IG000"
1066
-
)
1067
-
]
1068
-
1069
-
# suggested fix
1070
-
from fixit.common.base import CstLintRule
1071
-
classFakeRule(CstLintRule):
1072
-
INVALID= [
1073
-
Invalid(
1074
-
code="",
1075
-
)
1076
-
]
1077
-
1078
968
.. class:: UseClsInClassmethod
1079
969
1080
970
Enforces using ``cls`` as the first argument in a ``@classmethod``.
@@ -1184,44 +1074,6 @@ Built-in Rules
1184
1074
# suggested fix
1185
1075
f"{'hi'}"
1186
1076
1187
-
.. class:: UseLintFixmeComment
1188
-
1189
-
To silence a lint warning, use ``lint-fixme`` (when plans to fix the issue later) or ``lint-ignore``
1190
-
(when the lint warning is not valid) comments.
1191
-
The comment requires to be in a standalone comment line and follows the format ``lint-fixme: RULE_NAMES EXTRA_COMMENTS``.
1192
-
It suppresses the lint warning with the RULE_NAMES in the next line.
1193
-
RULE_NAMES can be one or more lint rule names separated by comma.
1194
-
``noqa`` is deprecated and not supported because explicitly providing lint rule names to be suppressed
1195
-
in lint-fixme comment is preferred over implicit noqa comments. Implicit noqa suppression comments
1196
-
sometimes accidentally silence warnings unexpectedly.
1197
-
1198
-
.. attribute:: MESSAGE
1199
-
1200
-
noqa is deprecated. Use `lint-fixme` or `lint-ignore` instead.
1201
-
1202
-
1203
-
.. attribute:: VALID
1204
-
1205
-
.. code:: python
1206
-
1207
-
# lint-fixme: UseFstringRule
1208
-
"%s"%"hi"
1209
-
.. code:: python
1210
-
1211
-
# lint-ignore: UsePlusForStringConcatRule
1212
-
'ab''cd'
1213
-
1214
-
.. attribute:: INVALID
1215
-
1216
-
.. code:: python
1217
-
1218
-
fn() # noqa
1219
-
.. code:: python
1220
-
1221
-
(
1222
-
1,
1223
-
2, # noqa
1224
-
)
1225
1077
.. class:: UseTypesFromTyping
1226
1078
1227
1079
Enforces the use of types from the ``typing`` module in type annotations in place
@@ -1263,6 +1115,109 @@ Built-in Rules
1263
1115
deffunction(list: list[str]) -> None:
1264
1116
pass
1265
1117
1118
+
``fixit.rules.extra``
1119
+
^^^^^^^^^^^^^^^^^^^^^
1120
+
1121
+
.. automodule:: fixit.rules.extra
1122
+
1123
+
- :class:`ExplicitFrozenDataclass`
1124
+
- :class:`UseLintFixmeComment`
1125
+
1126
+
.. class:: ExplicitFrozenDataclass
1127
+
1128
+
Encourages the use of frozen dataclass objects by telling users to specify the
1129
+
kwarg.
1130
+
1131
+
Without this lint rule, most users of dataclass won't know to use the kwarg, and
1132
+
may unintentionally end up with mutable objects.
1133
+
1134
+
.. attribute:: MESSAGE
1135
+
1136
+
When using dataclasses, explicitly specify a frozen keyword argument. Example: `@dataclass(frozen=True)` or `@dataclass(frozen=False)`. Docs: https://docs.python.org/3/library/dataclasses.html
1137
+
1138
+
.. attribute:: AUTOFIX
1139
+
:type: Yes
1140
+
1141
+
1142
+
.. attribute:: VALID
1143
+
1144
+
.. code:: python
1145
+
1146
+
@some_other_decorator
1147
+
classCls: pass
1148
+
.. code:: python
1149
+
1150
+
from dataclasses import dataclass
1151
+
@dataclass(frozen=False)
1152
+
classCls: pass
1153
+
1154
+
.. attribute:: INVALID
1155
+
1156
+
.. code:: python
1157
+
1158
+
from dataclasses import dataclass
1159
+
@some_unrelated_decorator
1160
+
@dataclass# not called as a function
1161
+
@another_unrelated_decorator
1162
+
classCls: pass
1163
+
1164
+
# suggested fix
1165
+
from dataclasses import dataclass
1166
+
@some_unrelated_decorator
1167
+
@dataclass(frozen=True) # not called as a function
1168
+
@another_unrelated_decorator
1169
+
classCls: pass
1170
+
1171
+
.. code:: python
1172
+
1173
+
from dataclasses import dataclass
1174
+
@dataclass() # called as a function, no kwargs
1175
+
classCls: pass
1176
+
1177
+
# suggested fix
1178
+
from dataclasses import dataclass
1179
+
@dataclass(frozen=True) # called as a function, no kwargs
1180
+
classCls: pass
1181
+
1182
+
.. class:: UseLintFixmeComment
1183
+
1184
+
To silence a lint warning, use ``lint-fixme`` (when plans to fix the issue later) or ``lint-ignore``
1185
+
(when the lint warning is not valid) comments.
1186
+
The comment requires to be in a standalone comment line and follows the format ``lint-fixme: RULE_NAMES EXTRA_COMMENTS``.
1187
+
It suppresses the lint warning with the RULE_NAMES in the next line.
1188
+
RULE_NAMES can be one or more lint rule names separated by comma.
1189
+
``noqa`` is deprecated and not supported because explicitly providing lint rule names to be suppressed
1190
+
in lint-fixme comment is preferred over implicit noqa comments. Implicit noqa suppression comments
1191
+
sometimes accidentally silence warnings unexpectedly.
1192
+
1193
+
.. attribute:: MESSAGE
1194
+
1195
+
noqa is deprecated. Use `lint-fixme` or `lint-ignore` instead.
0 commit comments