-
Notifications
You must be signed in to change notification settings - Fork 233
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
Update to Pyre-0.9.21 #1734
Update to Pyre-0.9.21 #1734
Conversation
Yes, the "Conformant" and "Notes" fields should be updated. Ideally "Conformant" should mirror the conclusion from the automated check, but there may be some remaining cases where we need a manual override.
I think the problem here is that pyre outputs "errors" for reveal_type(), while pyright and mypy output some lower-severity diagnostic. Either decision is fine and acceptable but the tests currently are written assuming the second option. I'll have to think of a way to represent this in the automatic conformance scoring, but for now I think you should mark Pyre as passing for this test. |
Thanks @stroxler, this is great progress! After looking through all of the changes, I think the following manual scoring updates should be made:
|
Thanks! There are a lot of changes here and I'm trying to do a quick pass through every module, in particular updating the notes where we need to (quite a few of the previous notes were due to us not having I'll double check the ones you flagged @erictraut; I think for I think I might mark |
Edit the notes where there were obvious updates, particularly related to changes because of `assert_type` being supported. Mark a few tests as Passing that were not before, and some others as either Unsupported or Partial where they were previously marked as better-supported (many of these are again related to `assert_type`; improved support for that makes it clearer that in a few cases Pyre was not conformant but appeared to be due to not throwing errors).
I've finished my manual adjustments. I updated a few tests beyond the ones @erictraut, and decided that I'll ask the team about whether we're okay taking an action item to make The main other things I came across:
|
The spec for x = 1
assert_type(x, Literal[1]) # No error in pyright but error in mypy This is why most of the tests are written in functions where the parameters have explicit type annotations: def func1(x: int):
assert_type(x, int)
I'd prefer to update the conformance tests not to trigger these errors by always initializing. I tried to do that consistently when writing the tests, but there are apparently some cases that I missed (probably masked at the time due to other issues). Please feel free to update the tests accordingly — or let me know if you'd prefer that I do it. Either is fine with me.
There is a mechanism that allows for errors to be reported on one of several different lines. You can read about the details in the README.txt. In short, it involves adding multiple |
The changes look good to me. Merging. |
Pyre's current behavior is that
This leads to error diffs on quite a few tests. It seems like most of these tests don't use assert_type on literals directly, but they do use cases where Pyre is able to infer a literal type and then propagate it into a generic context. For example, Pyre preserves a literal type here: The function being called is Other examples involved generic classes constructed out of literals... in these cases Pyre will frequently infer the generic to be over a literal type. This isn't necessarily good or user-friendly behavior, it can force them to use type annotations, but I don't think it's spec-violating either. We could probably make Pyre smart enough to optionally weaken literal types whenever that would make |
Ah, so this is a constraint solver issue. As with type inference, constraint solver behaviors are not specified in the typing spec. I didn't realize that any type checker retained literals in its constraint solver. Pyright doesn't retain literals in this case unless there is a constraint that requires it. Mypy generally doesn't retain literals, but there are cases where it does. Its behavior is inconsistent. I'm surprised that pyre retains literals in this case. I'm not convinced this is type safe. I don't think it's true that "only the identity can have that signature". For example: def func[T: int](x: T) -> T:
return type(x)(x + 1)
I don't think that's the right answer. That would defeat the purpose of |
I followed the instructions in CONTRIBUTING:
Changes to Pyre reflected here:
assert_type
, whichassert_type
testwhere Pyre is actually not conformant and our lack of assert_type support was hiding it
typing.reveal_type
supportOpen questions for reviewers:
conformant
field in some places where the automated conformance results changedreveal_type
are auto-marked as failing but I think Pyre is outputting as expectedhere, should I mark it as passing (or partial) in the
conformant
field?