-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Bug 🪲C: unsubscriptable-objectIssues related to 'unsubscriptable-object' checkIssues related to 'unsubscriptable-object' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codetyping
Milestone
Description
Apparently even the master branch code does not yet play well with a common pattern used to add type hints. The linked example is not unique, the same pattern can be seen in many places.
While adding # pylint: disable=unsubscriptable-object
can be used as a temporary workaround, it worth creating a bug as the more people will be adopting type hints, the more such problems we will face.
import os
from typing import TYPE_CHECKING, Any, Union
if TYPE_CHECKING:
BasePathLike = os.PathLike[Any] # <-- that is where pylint identifies E1136
else:
BasePathLike = os.PathLike
foo : Union[str, BasePathLike] = "bar"
Current behavior
example.py:5:19: E1136: Value 'os.PathLike' is unsubscriptable (unsubscriptable-object)
Expected behavior
Pass the linting as the code below is correct.
pylint --version output
2.6.0 and master, on python 3.9
ajeetdsouza, andreymal, rhtenhove and bbc2
Metadata
Metadata
Assignees
Labels
Bug 🪲C: unsubscriptable-objectIssues related to 'unsubscriptable-object' checkIssues related to 'unsubscriptable-object' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codetyping