no error when `Any` type in narrowed generic when the no `Any` flags are enabled
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
foo: object
if isinstance(foo, list):
a = foo[1]
reveal_type(a) # Any
a.asdfasdfasdf # no error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Python snippet in the linked mypy-play example with the listed no-Any flags enabled, and confirm the revealed type and missing attribute error. Trace the type narrowing and generic list-item inference involved, then verify that the invalid attribute access is rejected without introducing unrelated diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100