forked from wemake-services/wemake-python-styleguide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsistency.py
More file actions
2467 lines (1746 loc) · 56.9 KB
/
consistency.py
File metadata and controls
2467 lines (1746 loc) · 56.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
These checks limit Python's inconsistencies.
We can do the same things differently in Python.
For example, there are three ways to format a string.
There are several ways to write the same number.
We like our code to be consistent.
It is easier to work with your code base if you follow these rules.
So, we choose a single way to do things.
It does not mean that we choose the best way to do it.
But, we value consistency more than being 100% right
and we are ready to suffer all trade-offs that might come.
Once again, these rules are highly subjective, but we love them.
.. currentmodule:: wemake_python_styleguide.violations.consistency
"""
from typing import final
from wemake_python_styleguide.violations.base import (
ASTViolation,
TokenizeViolation,
)
@final
class LocalFolderImportViolation(ASTViolation):
"""
Forbid imports relative to the current folder.
Reasoning:
We should pick one style and stick to it.
We have decided to use the explicit one.
Solution:
Refactor your imports to use the absolute path.
Example::
# Correct:
from my_package.version import get_version
# Wrong:
from .version import get_version
from ..drivers import MySQLDriver
.. versionadded:: 0.1.0
"""
error_template = 'Found local folder import'
code = 300
@final
class DottedRawImportViolation(ASTViolation):
"""
Forbid imports like ``import os.path``.
Reasoning:
There are too many ways to import something.
We should pick one style and stick to it.
We have decided to use the readable one.
Solution:
Refactor your import statement.
Example::
# Correct:
from os import path
# Wrong:
import os.path
.. versionadded:: 0.1.0
"""
error_template = 'Found dotted raw import: {0}'
code = 301
@final
class UnicodeStringViolation(TokenizeViolation):
"""
Forbid ``u`` string prefix.
Reasoning:
We haven't needed this prefix since ``python2``,
but it is still possible to find it in a codebase.
Solution:
Remove this prefix.
Example::
# Correct:
nickname = 'sobolevn'
file_contents = b'aabbcc'
# Wrong:
nickname = u'sobolevn'
.. versionadded:: 0.1.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This rule is covered by ``ruff`` linter. See ``UP025``.
"""
code = 302
error_template = 'Found unicode string prefix: {0}'
disabled_since = '1.0.0'
@final
class UnderscoredNumberViolation(TokenizeViolation):
"""
Forbid underscores (``_``) in numbers.
Reasoning:
It is possible to write ``1000`` in three different ways:
``1_000``, ``10_00``, and ``100_0``.
And it would be still the same number.
Count how many ways there are to write bigger numbers.
Currently, it all depends on the cultural habits of the author.
We enforce a single way to write numbers with thousands separators.
We allow only underscores to be used as thousands separators.
Solution:
Numbers should be written as numbers: ``1000``.
Using underscores as thousands separators if necessary.
Example::
# Correct:
phone = 88313443
million = 1_000_000.50_001
hexed = 1_234.157_000e-1_123
binary = 0b1_001_001
# Wrong:
phone = 8_83_134_43
million = 100_00_00.1_0
octal = 0o00_11
.. versionadded:: 0.1.0
.. versionchanged:: 1.0.0
Underscore ``_`` is now allowed with exactly 3 digits after it.
"""
code = 303
error_template = 'Found underscored number: {0}'
@final
class PartialFloatViolation(TokenizeViolation):
"""
Forbid partial floats like ``.05`` or ``23.``.
Reasoning:
Partial numbers are hard to read and they can be confused with
other numbers. For example, it is really
easy to confuse ``0.5`` and ``.05`` when reading
through the source code.
Solution:
Use full versions with leading and trailing zeros.
Example::
# Correct:
half = 0.5
ten_float = 10.0
# Wrong:
half = .5
ten_float = 10.
.. versionadded:: 0.1.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
code = 304
error_template = 'Found partial float: {0}'
disabled_since = '1.0.0'
@final
class FormattedStringViolation(ASTViolation):
"""
Forbid ``f`` strings.
Reasoning:
``f`` strings implicitly rely on the context around them.
Imagine that you have a string that breaks
when you move it two lines above.
That's not how a string should behave.
Also, they promote a bad practice:
putting your logic inside the template.
Moreover, they do two things at once:
declare a template and format it in a single action.
Solution:
Use ``.format()`` with indexed params instead.
See also:
https://github.com/xZise/flake8-string-format
Example::
# Correct:
'Result is: {0}'.format(2 + 2)
'Hey {user}! How are you?'.format(user='sobolevn')
# Wrong:
f'Result is: {2 + 2}'
.. versionadded:: 0.1.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` linter. See ``WPS237``.
"""
error_template = 'Found `f` string'
code = 305
disabled_since = '1.0.0'
@final
class ExplicitObjectBaseClassViolation(ASTViolation):
"""
Forbid writing explicit `object` base class.
Reasoning:
Adding `object` base class does not have any effect in most cases.
However, PEP695 adds new syntax to define classes: `class Some[T]:`
which is equivalent to: `class Some(Generic[T]):`.
If `object` is added to `class Some[T](object):`
it will be a runtime error: it won't be possible to create a proper MRO.
We don't want to promote feature that can cause troubles.
This feature also has some legacy Python2 connotations.
Solution:
Remove `object` base class.
Example::
# Correct:
class Some: ...
# Wrong:
class Some(object): ...
.. versionadded:: 0.1.0
.. versionchanged:: 0.19.0
Now the rule is inverted: we require no explicit `object` base class.
See PEP695 for extra reasoning.
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
error_template = 'Found explicit `object` base class: {0}'
code = 306
disabled_since = '1.0.0'
@final
class MultipleIfsInComprehensionViolation(ASTViolation):
"""
Forbid multiple ``if`` statements inside list comprehensions.
Reasoning:
It is very hard to read multiple ``if`` statements inside
a list comprehension. Since it is even hard to tell all of them
should pass or fail.
Solution:
Use a single ``if`` statement inside list comprehensions.
Use ``filter()`` if you have complicated logic.
Example::
# Correct:
nodes = [node for node in html if node not in {'b', 'i'}]
# Wrong:
nodes = [node for node in html if node != 'b' if node != 'i']
.. versionadded:: 0.1.0
"""
error_template = 'Found a comprehension with multiple `if`s'
code = 307
@final
class ConstantCompareViolation(ASTViolation):
"""
Forbid comparing between two literals.
Reasoning:
When two constants are compared it is typically an indication of a
mistake, since the Boolean value of the comparison, will always be
the same.
Solution:
Remove the constant comparison and any associated dead code.
Example::
# Correct:
do_something_else()
# Wrong:
if 60 * 60 < 1000:
do_something()
else:
do_something_else()
.. versionadded:: 0.3.0
"""
error_template = 'Found constant comparison'
code = 308
@final
class CompareOrderViolation(ASTViolation):
"""
Forbid comparisons where the argument doesn't come first.
Reasoning:
It is hard to read the code when
you have to shuffle the ordering of the arguments all the time.
Bring consistency to the comparison!
Solution:
Refactor your comparison expression, place the argument first.
Example::
# Correct:
if some_x > 3:
if 3 < some_x < 10:
# Wrong:
if 3 < some_x:
.. versionadded:: 0.3.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` linter. See ``SIM300``.
"""
error_template = 'Found reversed compare order'
code = 309
disabled_since = '1.0.0'
@final
class BadNumberSuffixViolation(TokenizeViolation):
"""
Forbid uppercase ``X``, ``O``, ``B``, and ``E`` in numbers.
Reasoning:
Octal, hex, binary and scientific notation suffixes could
be written in two possible notations: lowercase and uppercase
which brings confusion and decreases code consistency and readability.
We enforce a single way to write numbers with suffixes:
suffix with lowercase chars.
Solution:
Octal, hex, binary and scientific notation suffixes in numbers
should be written in lowercase.
Example::
# Correct:
hex_number = 0xFF
octal_number = 0o11
binary_number = 0b1001
number_with_scientific_notation = 1.5e+10
# Wrong:
hex_number = 0XFF
octal_number = 0O11
binary_number = 0B1001
number_with_scientific_notation = 1.5E+10
.. versionadded:: 0.3.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
error_template = 'Found bad number suffix: {0}'
code = 310
disabled_since = '1.0.0'
@final
class MultipleInCompareViolation(ASTViolation):
"""
Forbid comparisons with multiple ``in`` checks.
Reasoning:
Using multiple ``in`` checks is unreadable.
Solution:
Refactor your comparison expression to use several ``and`` conditions
or separate ``if`` statements in cases where it is appropriate.
Example::
# Correct:
if item in bucket and bucket in master_list_of_buckets:
if x_coord not in line and line not in square:
# Wrong:
if item in bucket in master_list_of_buckets:
if x_cord not in line not in square:
.. versionadded:: 0.3.0
.. versionchanged:: 0.10.0
"""
error_template = 'Found multiple `in` compares'
code = 311
@final
class UselessCompareViolation(ASTViolation):
"""
Forbid comparisons of a variable to itself.
Reasoning:
When a variable is compared to itself, it is typically an indication
of a mistake since the Boolean value of the comparison will always be
the same.
Solution:
Remove the comparison and any associated dead code.
Example::
# Correct:
do_something()
# Wrong:
if a < a:
do_something()
else:
do_something_else()
.. versionadded:: 0.3.0
.. versionchanged:: 1.0.1
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` and ``pylint`` linters. See ``PLR0124``.
"""
error_template = 'Found comparison of a variable to itself'
code = 312
disabled_since = '1.0.1'
@final
class MissingSpaceBetweenKeywordAndParenViolation(TokenizeViolation):
"""
Enforce separation of parenthesis from keywords with spaces.
Reasoning:
Some people use ``return`` and ``yield`` keywords as functions.
The same happened to good old ``print`` in Python2.
Solution:
Insert space symbol between the keyword and opening parenthesis.
Example::
# Correct:
def func():
a = 1
del (a, b)
yield (1, 2, 3)
# Wrong:
def func():
a = 1
b = 2
del(a, b)
yield(1, 2, 3)
.. versionadded:: 0.3.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
error_template = 'Found parenthesis immediately after a keyword'
code = 313
disabled_since = '1.0.0'
@final
class ConstantConditionViolation(ASTViolation):
"""
Forbid using ``if`` or ``match`` statements that use invalid conditionals.
Reasoning:
When invalid conditional arguments are used
it is typically an indication of a mistake, since
the value of the conditional result will always be the same.
Solution:
Remove the conditional and any associated dead code.
Example::
# Correct:
if value is True: ...
match value:
case True:
...
# Wrong:
if True: ...
match True:
case True: ...
.. versionadded:: 0.3.0
"""
error_template = 'Found conditional that always evaluates the same'
code = 314
@final
class ObjectInBaseClassesListViolation(ASTViolation):
"""
Forbid extra ``object`` in parent classes list.
Reasoning:
We should allow object only when
we explicitly use it as a single parent class.
When there is another class or there are multiple
parents - we should not allow it for the consistency reasons.
Solution:
Remove extra ``object`` parent class from the list.
Example::
# Correct:
class SomeClassName: ...
class SomeClassName(FirstParentClass, SecondParentClass): ...
# Wrong:
class SomeClassName(FirstParentClass, SecondParentClass, object): ...
.. versionadded:: 0.3.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` linter. See ``UP004``.
"""
error_template = 'Found extra `object` in parent classes list: {0}'
code = 315
disabled_since = '1.0.0'
@final
class MultipleContextManagerAssignmentsViolation(ASTViolation):
"""
Forbid multiple assignment targets for context managers.
Reasoning:
It is hard to distinguish whether ``as`` should unpack into
a tuple or if we are just using two context managers.
Solution:
Use several context managers or explicit brackets.
Example::
# Correct:
with open('') as first:
with second:
...
with some_context as (first, second):
...
# Wrong:
with open('') as first, second:
...
.. versionadded:: 0.6.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter. See ``SIM117``.
"""
error_template = 'Found context manager with too many assignments'
code = 316
disabled_since = '1.0.0'
@final
class ParametersIndentationViolation(ASTViolation):
"""
Forbid incorrect indentation for parameters.
Reasoning:
It is really easy to spoil your perfect, readable code with
incorrect multi-line parameters indentation.
Since it is really easy to style them in any of 100 possible ways.
We enforce a strict rule about how it is possible to write these
multi-line parameters.
Solution:
Use consistent multi-line parameters indentation.
Example::
# Correct:
def my_function(arg1, arg2, arg3) -> None:
return None
print(1, 2, 3, 4, 5, 6)
def my_function(
arg1, arg2, arg3,
) -> None:
return None
print(
1, 2, 3, 4, 5, 6,
)
def my_function(
arg1,
arg2,
arg3,
) -> None:
return None
print(
first_variable,
2,
third_value,
4,
5,
last_item,
)
# Special case:
print('some text', 'description', [
first_variable,
second_variable,
third_variable,
last_item,
], end='')
# Correct complex case:
@pytest.mark.parametrize(('boolean_arg', 'string_arg'), [
(True, "string"),
(False, "another string"),
])
Everything else is considered a violation.
This rule checks: lists, sets, tuples, dicts, calls,
functions, methods, and classes.
.. versionadded:: 0.6.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
error_template = 'Found incorrect multi-line parameters'
code = 317
disabled_since = '1.0.0'
@final
class ExtraIndentationViolation(TokenizeViolation):
"""
Forbid extra indentation.
Reasoning:
You can use extra indentation for lines of code.
Python allows you to do that in case you want to keep the
indentation level equal for this specific node,
but that's insane!
Solution:
We should stick to 4 spaces for an indentation block.
Each next block level should be indented by just 4 extra spaces.
Example::
# Correct:
def test():
print('test')
# Wrong:
def test():
print('test')
This rule is consistent with the "Vertical Hanging Indent" option for
``multi_line_output`` setting of ``isort``. To avoid conflicting rules,
you should set ``multi_line_output = 3`` in the ``isort`` settings.
See also:
https://github.com/timothycrosley/isort#multi-line-output-modes
https://github.com/wemake-services/wemake-python-styleguide/blob/master/styles/isort.toml
.. versionadded:: 0.6.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
error_template = 'Found extra indentation'
code = 318
disabled_since = '1.0.0'
@final
class WrongBracketPositionViolation(TokenizeViolation):
"""
Forbid brackets in the wrong position.
Reasoning:
You can do bizarre things with bracket positioning in python.
We require all brackets to be consistent.
Solution:
Place bracket on the same line, in case of a single line expression.
Or place the bracket on a new line in case of a multi-line expression.
Example::
# Correct:
print([
1, 2, 3,
])
print(
1,
2,
)
def _annotate_brackets(
tokens: List[tokenize.TokenInfo],
) -> TokenLines:
...
# Wrong:
print([
1, 2, 3],
)
print(
1,
2)
def _annotate_brackets(
tokens: List[tokenize.TokenInfo]) -> TokenLines:
...
We check round, square, and curly brackets.
.. versionadded:: 0.6.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
error_template = 'Found bracket in wrong position'
code = 319
disabled_since = '1.0.0'
@final
class MultilineFunctionAnnotationViolation(ASTViolation):
"""
Forbid multi-line function type annotations.
Reasoning:
Functions with multi-line type annotations are unreadable.
Solution:
Use type annotations that fit into a single line to annotate functions.
If your annotation is too long, then use type aliases.
Example::
# Correct:
def create_list(length: int) -> List[int]:
...
# Wrong:
def create_list(length: int) -> List[
int,
]:
...
This rule checks argument and return type annotations.
.. versionadded:: 0.6.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter.
"""
error_template = 'Found multi-line function type annotation'
code = 320
disabled_since = '1.0.0'
@final
class UppercaseStringModifierViolation(TokenizeViolation):
"""
Forbid uppercase string modifiers.
Reasoning:
String modifiers should be consistent.
Solution:
Use lowercase string modifiers.
Example::
# Correct:
some_string = r'/regex/'
some_bytes = b'123'
# Wrong:
some_string = R'/regex/'
some_bytes = B'123'
.. versionadded:: 0.6.0
"""
error_template = 'Found uppercase string modifier: {0}'
code = 321
@final
class UselessMultilineStringViolation(TokenizeViolation):
r'''
Forbid triple quotes for singleline strings.
Reasoning:
String quotes should be consistent.
Solution:
Use single quotes for single-line strings.
Triple quotes are only allowed for real multiline strings.
Example::
# Correct:
single_line = 'abc'
multiline = """
one
two
"""
# Wrong:
some_string = """abc"""
some_bytes = b"""123"""
Docstrings are ignored from this rule.
You must use triple quotes strings for docstrings.
Is not reported for `f`-strings on python3.12+
.. versionadded:: 0.7.0
.. versionchanged:: 1.0.0
Now allows to have multiline strings without ``\n``
when that string is the single token on each line.
Also changed how multiline strings are detected.
'''
error_template = 'Found incorrect multi-line string'
code = 322
@final
class ModuloStringFormatViolation(ASTViolation):
"""
Forbid ``%`` formatting on strings.
We check for string formatting. We try not to issue false positives.
It is better for us to ignore a real (but hard to detect) case,
then marking a valid one as incorrect.
Internally we check for this pattern in string definitions::
%[(name)] [flags] [width] [.precision] [{h | l}] type
This is a ``C`` format specification.
Related to :class:`~FormattedStringViolation` and solves the same problem.
Reasoning:
You must use a single formatting method across your project.
Solution:
We enforce to use string ``.format()`` method for this task.
Example::
# Correct:
'some string', 'your name: {0}', 'data: {data}'
# Wrong:
'my name is: %s', 'data: %(data)d'
It might be a good idea to disable this rule
and switch to ``flake8-pep3101`` in case your project
has a lot of false-positives due
to some specific string chars that uses ``%`` a lot.
See also:
https://github.com/gforcada/flake8-pep3101
https://msdn.microsoft.com/en-us/library/56e442dc.aspx
https://docs.python.org/3/library/stdtypes.html#old-string-formatting
https://pyformat.info/
.. versionadded:: 0.14.0
.. versionchanged:: 1.0.0
No longer produced, kept here for historic reasons.
This is covered with ``ruff`` formatter. See ``UP031``.
"""
error_template = 'Found `%` string formatting'
code = 323
disabled_since = '1.0.0'
@final
class InconsistentReturnViolation(ASTViolation):
"""
Enforce consistent ``return`` statements.
Rules are:
1. If any ``return`` has a value, all ``return`` nodes should have a value
2. Do not place ``return`` without a value at the end of a function
3. Do not use ``return None`` where just ``return`` is good enough
This rule respects ``mypy`` style of placing ``return`` statements.
There should be no conflict with these two checks.
Reasoning:
This is done for pure consistency and readability of your code.
Eventually, this rule may also find some bugs in your code.
Solution:
Add or remove values from the ``return`` statements
to make them consistent.
Remove ``return`` statement from the function end.
Example::