File tree Expand file tree Collapse file tree 5 files changed +13
-9
lines changed Expand file tree Collapse file tree 5 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ Code Style checker Messages
88
88
'typing.NamedTuple' uses the well-known 'class' keyword with type-hints for
89
89
readability (it's also faster as it avoids an internal exec call). Disabled
90
90
by default!
91
+ :use-math-not-float (R6106): *%smath.%s is preferable to %s *
92
+ Using math.inf or math.nan permits to benefit from typing and it is 4 time
93
+ faster than a float call (notwithstanding the initial import of math).
91
94
92
95
93
96
.. _pylint.extensions.comparison_placement :
Original file line number Diff line number Diff line change @@ -689,11 +689,11 @@ Match Statements checker Messages
689
689
:invalid-match-args-definition (E1902): *`__match_args__` must be a tuple of strings. *
690
690
Emitted if `__match_args__ ` isn't a tuple of strings required for match.
691
691
:too-many-positional-sub-patterns (E1903): *%s expects %d positional sub-patterns (given %d) *
692
- Emitted when the number of allowed positional sub-patterns exceeds the
693
- number of allowed sub-patterns specified in `__match_args__ `.
692
+ Emitted when the number of allowed positional sub-patterns exceeds the number
693
+ of allowed sub-patterns specified in `__match_args__ `.
694
694
:multiple-class-sub-patterns (E1904): *Multiple sub-patterns for attribute %s *
695
- Emitted when there is more than one sub-pattern for a specific attribute in
696
- a class pattern.
695
+ Emitted when there is more than one sub-pattern for a specific attribute in a
696
+ class pattern.
697
697
:match-class-bind-self (R1905): *Use '%s() as %s' instead *
698
698
Match class patterns are faster if the name binding happens for the whole
699
699
pattern and any lookup for `__match_args__ ` can be avoided.
Original file line number Diff line number Diff line change @@ -559,6 +559,7 @@ All messages in the refactor category:
559
559
refactor/use-a-generator
560
560
refactor/use-dict-literal
561
561
refactor/use-list-literal
562
+ refactor/use-math-not-float
562
563
refactor/use-set-for-membership
563
564
refactor/use-yield-from
564
565
refactor/useless-object-inheritance
Original file line number Diff line number Diff line change 1
- Add a ``use-math-not-float`` message. float("nan") and float("inf") are slower
2
- than their counterpart ``math.inf`` and ``math.nan`` by a factor of 4 and they
3
- are also not well typed when using mypy.
1
+ Add a ``use-math-not-float`` message. `` float("nan")`` and `` float("inf")`` are slower
2
+ than their counterpart ``math.inf`` and ``math.nan`` by a factor of 4 (notwithstanding
3
+ the initial import of math) and they are also not well typed when using mypy.
4
4
5
5
The :ref:`pylint.extensions.code_style` need to be activated for this check to work.
6
6
Original file line number Diff line number Diff line change @@ -78,8 +78,8 @@ class CodeStyleChecker(BaseChecker):
78
78
"%smath.%s is preferable to %s" ,
79
79
"use-math-not-float" ,
80
80
"Using math.inf or math.nan permits to benefit from typing "
81
- "and it is 4 time faster than a float call. \n "
82
- "Requires 'import math' in the file ." ,
81
+ "and it is 4 time faster than a float call (notwithstanding "
82
+ " the initial import of math) ." ,
83
83
),
84
84
}
85
85
options = (
You can’t perform that action at this time.
0 commit comments