Skip to content

[Python 3.9] Value 'Optional' is unsubscriptable (unsubscriptable-object) (also Union) #3882

Closed
@hjwp

Description

@hjwp

Steps to reproduce

Install Python 3.9, then:

# minimal_repro.py
from typing import Optional, Union
foo: Optional[int] = 3
bar: Union[int, str] = 4

Current behavior

Pylint reports

minimal_repro.py:3:5: E1136: Value 'Optional' is unsubscriptable (unsubscriptable-object)
minimal_repro.py:4:5: E1136: Value 'Union' is unsubscriptable (unsubscriptable-object)

Expected behavior

This isn't an error in Python 3.8 so I don't think it should be an error in 3.9?

pylint --version output

pylint 2.6.0
astroid 2.4.2

(I tried pip install pylint astroid --pre -U)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions