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
8888 'typing.NamedTuple' uses the well-known 'class' keyword with type-hints for
8989 readability (it's also faster as it avoids an internal exec call). Disabled
9090 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).
9194
9295
9396.. _pylint.extensions.comparison_placement :
Original file line number Diff line number Diff line change @@ -689,11 +689,11 @@ Match Statements checker Messages
689689:invalid-match-args-definition (E1902): *`__match_args__` must be a tuple of strings. *
690690 Emitted if `__match_args__ ` isn't a tuple of strings required for match.
691691: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__ `.
694694: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.
697697:match-class-bind-self (R1905): *Use '%s() as %s' instead *
698698 Match class patterns are faster if the name binding happens for the whole
699699 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:
559559 refactor/use-a-generator
560560 refactor/use-dict-literal
561561 refactor/use-list-literal
562+ refactor/use-math-not-float
562563 refactor/use-set-for-membership
563564 refactor/use-yield-from
564565 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.
44
55The :ref:`pylint.extensions.code_style` need to be activated for this check to work.
66
Original file line number Diff line number Diff line change @@ -78,8 +78,8 @@ class CodeStyleChecker(BaseChecker):
7878 "%smath.%s is preferable to %s" ,
7979 "use-math-not-float" ,
8080 "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) ." ,
8383 ),
8484 }
8585 options = (
You can’t perform that action at this time.
0 commit comments