[red-knot] Trust all symbols in stub files#17588
Conversation
|
|
Oh, I suppose a lot of class-level assignments in typeshed are in the context of enum classes (e.g. https://github.com/python/typeshed/blob/ae57d69c9354147bcf7086d6db47af8f8c82bf7b/stdlib/re.pyi#L201-L221 ), and we infer all attributes on enums as |
|
I found one example that we do infer differently on this branch! I'm sure it's widely used: from pdb import Pdb
reveal_type(Pdb.do_b) # Previously: Unknown | def do_break(self, arg: str, temporary: bool = EllipsisType) -> bool | None
# Now: def do_break(…) -> … |
|
This does still feel more consistent to me, so I do support it still! |
6f727ff to
c00dad7
Compare
carljm
left a comment
There was a problem hiding this comment.
I think this makes sense as well. Sorry I didn't get through my notifications fast enough to comment on the previous PR sooner!
The core "gradual guarantee" idea that we should not emit false positives on working untyped code, when the user hasn't declared their intentions through type annotations, just doesn't apply to stub files in the same way, since they are inherently somebody explicitly providing type information.
Summary
Follow-up on the discussion here. Generally trust undeclared symbols in stubs, not just at the module level.
Test Plan
New Markdown test.