-
Notifications
You must be signed in to change notification settings - Fork 20
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
List[int] is incompatible with List[Union[float]] #67
Comments
Is this really about
That said, this behavior is correct in the sense that |
Sorry, it's really not about |
As far as I understand, the concepts of invariance/covariance are mostly actual when doing static type checking, when we have no information on actual variable contents, and can only talk about what is expected and what is acceptable. When doing a runtime check, the static typing information is not fully relevant, as it's not really used by runtime. In runtime, there's no difference between Moreover, there's no way to specify which of those is meant. For example, we can annotate return value (see the test in this issue), like So, in runtime, Though static type annotations are very useful for runtime type checking, it's clear to me that runtime type checking can NOT be performed exactly like static type checking is performed, it's a different matter and should use different logic. |
I understand the suggestion to use Also, I see the main purpose of tools like |
I am going to open a separate issue about the List-invariance and solution ideas. However don't expect a solution there soon. You can try the Regarding static vs runtime typechecking, maybe I can add some context: That said, I noticed that you are also active in typeguard. If you just need pytypes to enable stubfile support (Note: overload is currently not supported which rules out many stubfiles from typeshed) you may want to try using |
That's pretty understandable, for sure. Yes, I came from However I don't exactly understand how |
See #75. |
|
Closing this in favor of #76. |
The following code:
fails as follows:
The text was updated successfully, but these errors were encountered: