You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Function invocation pins type of arguments too early #105
i don't understand the initial example - if x is None coerces the type of x to None and then foo(x, y) could indeed fail typechecking if y is int, so pyrefly is doing the right thing there.
@martindemello If the typevar T for foo gets instantiated into int | None then type checking won't fail. i.e.
deffoo(a: int|None, b: int|None) ->int|None:
...
deftest(x: int|None, y: int|None) ->int|None:
ifxisNone:
returnfoo(x, y) # This should type checkreturnNone
We don't really want to assume the call foo(x, y) forces T to be None just because its first argument x is None -- the point here is that if we wait longer and get to see what the type of y is, we could have guessed better type for T.
This issue has someone assigned, but has not had recent activity for more than 2 weeks.
If you are still working on this issue, please add a comment so everyone knows. Otherwise, please unassign yourself and allow someone else to take over.
Most of the user-facing bugs that were reported on this issue and its duplicates have been closed, so I'm going to close out this issue and open a new one to track the remaining work (edge case bugs, internal solver improvements and cleanups).
Activity
lolpack commentedon May 1, 2025
Sandbox URL: https://pyrefly.org/sandbox/?code=CYUwZgBGD20NoBUC6AKAhgLgggNBARlggJQQC0AfNhgFAT0QB0zNNokALiAM4coAeWAJYA7DhAA+EAHLQRIPAE9hYyTLkhSlCKPFTZ82gx2R+O7usN1jDAE4gOAV1siosAUuLX69py8sgQA
dict.__init__when creating dict with different value types #562 as a duplicate of this issuedictfunction with distinct elements handled poorly #602 as a duplicate of this issuemartindemello commentedon Jun 29, 2025
i don't understand the initial example -
if x is Nonecoerces the type ofxtoNoneand thenfoo(x, y)could indeed fail typechecking ifyisint, so pyrefly is doing the right thing there.grievejia commentedon Jul 7, 2025
@martindemello If the typevar
Tforfoogets instantiated intoint | Nonethen type checking won't fail. i.e.We don't really want to assume the call
foo(x, y)forcesTto beNonejust because its first argumentxisNone-- the point here is that if we wait longer and get to see what the type ofyis, we could have guessed better type forT.samwgoldman commentedon Jul 7, 2025
If I understand, the following is a even simpler example where the eager pinning of generics can go awry:
github-actions commentedon Aug 5, 2025
This issue has someone assigned, but has not had recent activity for more than 2 weeks.
If you are still working on this issue, please add a comment so everyone knows. Otherwise, please unassign yourself and allow someone else to take over.
Thank you for your contributions!
226 remaining items
Take upper bounds into account in `solve_bounds`
Check upper bounds before promoting literals in lower bounds
Keep eager pinning for ParamSpec and TypeVarTuple
Check for upper bound violations before adding lower bounds
Collect upper bounds on Quantified and Unwrap
Remove unnecessary `is_partial` variable and check
Extract `add_bound` helper from `add_lower_bound`
Use `add_bound` in `add_upper_bound` (#2941)
rchen152 commentedon Apr 30, 2026
Most of the user-facing bugs that were reported on this issue and its duplicates have been closed, so I'm going to close out this issue and open a new one to track the remaining work (edge case bugs, internal solver improvements and cleanups).
Pyrefly: surface secondary annotations as LSP DiagnosticRelatedInform…
Pyrefly: surface secondary annotations as LSP DiagnosticRelatedInform…