Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Loading