Repository navigation
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D127555133. (Because this pull request was imported automatically, there will not be any future comments.) |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
stroxler
approved these changes
Oct 27, 2026
stroxler
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Contributor
|
This pull request has been merged in 413a7ef. |
meta-codesync Bot
pushed a commit
that referenced
this pull request
Nov 5, 2026
Summary:
Before, `x = set[int]()` would be treated as untyped, because `x` had no annotations. This is a bit silly though, since `set[int]` is already explicitly provided by the user, albeit on the RHS. This makes it so that `pyrefly coverage {report,coverage}` will consider `x` to be typed.
In case of unknown rhs, e.g. `from schrodinger import cat; cats = cat[None]()`, `cats` will still be considered untyped. Because `cat` could be a generic type, but it could also be `dict[None, () -> SomethingElse]` -- there's no way to tell 🤷.
I ran into this in the wild in [Hypothesis](https://github.com/HypothesisWorks/hypothesis/) recently:
- [`default_variable = DynamicVariable[Optional["settings"]](None)`](https://github.com/HypothesisWorks/hypothesis/blob/a2406edcd532e02400c8e20e6a131b791d3c11b6/hypothesis/src/hypothesis/_settings.py#L416)
- [`reporter = DynamicVariable[ReporterT](default)`](https://github.com/HypothesisWorks/hypothesis/blob/a2406edcd532e02400c8e20e6a131b791d3c11b6/hypothesis/src/hypothesis/reporting.py#L28)
- [x] I am a human <sub>(no way to know for sure, but I certainly hope so!)</sub>, and I fully understand the code I am submitting.
X-link: #5383
Reviewed By: stroxler
Differential Revision: D127555133
fbshipit-source-id: 726d371acad581fdc939d1947f82fb0ac904a124
1 task done
meta-codesync Bot
pushed a commit
that referenced
this pull request
Nov 11, 2026
…efly coverage` (#5613) Summary: Following #5383 and #5552, this relaxes the typable classifier some more for module-level, so that non-generic class constructors now also are counted as implicitly typed, e.g. `BASE_DIR = Path(".")`. - [x] I am a human, and I fully understand the code I am submitting. Pull Request resolved: #5613 Test Plan: there are tests Reviewed By: stroxler Differential Revision: D131224148 fbshipit-source-id: e7fceed6e1aca06f8805bb39cda81288bffa8f5b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Before,
x = set[int]()would be treated as untyped, becausexhad no annotations. This is a bit silly though, sinceset[int]is already explicitly provided by the user, albeit on the RHS. This makes it so thatpyrefly coverage {report,coverage}will considerxto be typed.In case of unknown rhs, e.g.
from schrodinger import cat; cats = cat[None](),catswill still be considered untyped. Becausecatcould be a generic type, but it could also bedict[None, () -> SomethingElse]-- there's no way to tell 🤷.I ran into this in the wild in Hypothesis recently:
default_variable = DynamicVariable[Optional["settings"]](None)reporter = DynamicVariable[ReporterT](default)I am a human (no way to know for sure, but I certainly hope so!), and I fully understand the code I am submitting.
Test Plan
Tests added