-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] implement disjointness of Callable vs SpecialForm #18503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
AlexWaygood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This special form is callable:
| TypedDict, |
|
|
@AlexWaygood It looks like |
|
The collections proxies are callable, but the builtins proxies aren't?! That's... Odd. I had in my head that all the legacy stdlib aliases were not callable! We should probably treat them as callable if they are at runtime — can we just delegate to the constructor signatures of the classes they're aliasing? I don't love the idea of hardcoding their constructors' signatures somewhere in our model — some of those classes have reasonably complicated constructor methods IIRC |
Yeah, that should be possible. It's beyond the scope of what I was looking to do in this PR, but I added a TODO for it. |
In that case, is there any reason not to just treat them as direct aliases? That is, remove their SpecialForm type entirely and act as if |
|
PEP 585 states:
I think pyright implements this deprecation, and it would be nice if we could eventually as well. If we didn't distinguish between Edit: Hmm, come to think of it, though, we'll have the same "tricky" issue when it comes to implementing deprecation warnings for Given that we'll maybe have to solve that issue for the |
It looks like the builtin aliases are specifically excluded from being callable at runtime by passing the |
88465fd to
f7a8479
Compare
Summary
Fixes astral-sh/ty#557
Test Plan
Stable property tests succeed with a million iterations. Added mdtests.