-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)
Description
Bug description
When using a NewType type definition based on Dict[str,str]
and using regular dict-access methods, this generates various false positive warnings, e.g. unsupported-assignment-operation
, unsubscriptable-object
.
Sample code:
from typing import Dict
from typing import NewType
DatasetTags = NewType("DatasetTags", Dict[str,str])
test = DatasetTags({})
test['toast'] = 5
b = test['toast']
Possibly related issues:
For Tuples: #4944
For Lists: #2296
Configuration
No response
Command used
pylint --disable=missing-docstring newtype_test.py
Pylint output
************* Module newtype_test
newtype_test.py:8:0: E1137: 'test' does not support item assignment (unsupported-assignment-operation)
newtype_test.py:9:4: E1136: Value 'test' is unsubscriptable (unsubscriptable-object)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
Expected behavior
No issues should be reported, as the dict-access is correct.
Pylint version
pylint 2.14.5
astroid 2.11.7
Python 3.11.0b5 (main, Aug 17 2022, 10:25:57) [Clang 13.1.6 (clang-1316.0.21.2.3)]
OS / Environment
MacOS on M1 Mac (arm64-architecture)
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)