-
Notifications
You must be signed in to change notification settings - Fork 235
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
Add conformance tests for basic generic spec #1553
Conversation
dd62ad9
to
78f1ece
Compare
concat(m, b) # Type error | ||
|
||
# TODO: should these be str or Any? | ||
# reveal_type(concat(m, a)) |
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 gets into constraint-solving behavior which is underspecified, but I'm still surprised to see that mypy generates an Any
in this case. That's not what I would expect, and it seems inconsistent with mypy's handling of non-constrained TypeVars.
class GenericMeta(type, Generic[T]): ... | ||
|
||
class GenericMetaInstance(metaclass=GenericMeta[T]): # Type error | ||
... |
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.
It may also be useful to add tests for accessing a TypeVar as a runtime object — to make sure that this isn't disallowed.
assert_type(T.__name__, str)
assert_type(T.__bound__, Any | None)
T.other # Type error
runtime_typevar: TypeVar = T # OK
@erictraut I don't think we expect any "derives from protocol but doesn't implement all methods" errors here, or at least I don't see any. On the following file pyright 1.1.345 has no complaints:
mypy, pyre and pytype are all fine with the class definition, but treat it as an abstract class and error when you attempt to instantiate. I can still add the missing methods if you want, but wanted to make sure I wasn't missing something / we should add this to the list of things to exactly specify. |
Yeah, that makes sense. After reviewing the text in the Explicitly Declaring Implementation section, I agree that pyright should emit those errors only if it's marked |
892f98b
to
09de5c8
Compare
Okay, this is mergeable. Remaining items:
|
No description provided.