Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/10708.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix crash for ``prefer-typing-namedtuple`` and ``consider-math-not-float`` when
a ``slice`` object is called.

Closes #10708
2 changes: 1 addition & 1 deletion pylint/extensions/code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def open(self) -> None:
def visit_call(self, node: nodes.Call) -> None:
if self._py36_plus:
called = safe_infer(node.func)
if not called:
if not (called and isinstance(called, (nodes.FunctionDef, nodes.ClassDef))):
return
if called.qname() == "collections.namedtuple":
self.add_message(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ class SearchMatch(
namedtuple('SearchMatch', ['els', 'index', 'iterator']) # [prefer-typing-namedtuple]
):
"""Adapted from primer package `music21`."""


# Regression test for https://github.com/pylint-dev/pylint/issues/10708
x = slice(42)
x() # pylint: disable=not-callable
5 changes: 5 additions & 0 deletions tests/functional/ext/code_style/cs_use_math_not_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@
upper_nan_float = float("NaN") # [consider-math-not-float]
typo_nan_float = float("nani") # [consider-math-not-float]
other_typo_nan_float = float("nna") # [consider-math-not-float]


# Regression test for https://github.com/pylint-dev/pylint/issues/10708
x = slice(42)
x() # pylint: disable=not-callable