Skip to content

False positive: Tuple claimed unsubscriptable when using NewType #4944

Open
@Kwasniok

Description

@Kwasniok

Bug description

# pylint: disable=C0114,W0104

from typing import NewType

MyTuple = NewType("T", tuple[float, float])
x = MyTuple((1.1, 2.2))
x[0]

Configuration

No response

Command used

pylint test.py

Pylint output

************* Module test
test.py:7:0: E1136: Value 'x' is unsubscriptable (unsubscriptable-object)


------------------------------------------------------------------
Your code has been rated at 3.75/10 (previous run: 3.75/10, +0.00)

Expected behavior


--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Pylint version

pylint 2.10.2
astroid 2.7.2
Python 3.9.6 (default, Jun 30 2021, 10:22:16) 
[GCC 11.1.0]

OS / Environment

cat /proc/version
Linux version 5.13.10-arch1-1 (linux@archlinux) (gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Thu, 12 Aug 2021 21:59:14 +0000

Additional dependencies

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid updateNeeds an astroid update (probably a release too) before being mergabletyping

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions