Skip to content

False positive E1126 (invalid-sequence-index) on generic type alias with forward ref #9908

Open
@dairiki

Description

@dairiki

Bug description

# pylint: disable=missing-docstring
from typing import TypeAlias, TypeVar

T = TypeVar("T")

Alias1: TypeAlias = list[T]
Alias2: TypeAlias = "list[T]"

x1: Alias1[int]  # ok
x2: Alias2[int]  # <= triggers E1126 (invalid-sequence-index)

Configuration

No response

Command used

pylint --rcfile /dev/null test.py

Pylint output

************* Module test
test.py:10:4: E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)

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

Expected behavior

Should not emit warning.

I've also tested with pylint from the head of the main branch (eb33f8a).

Pylint version

pylint 3.2.7
astroid 3.2.4
Python 3.12.5 (main, Aug  7 2024, 10:47:46) [GCC 11.4.0]

OS / Environment

Ubuntu 22.04

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codetyping

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions