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
When trying to fixMapping and MutableMapping definition in mypy, I got an error stating that it can't add a List[None] to a List[Frame] (or List[Constaint]), having these comments allow it to work.
Not much related, shouldn't it be infered as a List[Any] instead?
Not much related, shouldn't it be infered as a List[Any] instead?
It inferred the type Union[List[Constraint], List[None]] for a, then it tried to check a.append(con) with a having each type from the union.
Honestly I wish mypy was smart enough to figure out that the empty list in this case has the same type as the non-default list return value...
This reminds me of the situation with x if b else y where you implemented some special logic to type check y with the inferred type of x, IIRC. Seems sensible to do something similar here but I don't know how we'd tell mypy to do that.
In principle mypy could determine that the [] must have type List[Constraint] from the usage on the next line, but that is pretty far outside its capabilities at the moment.
What I did for [...] if ... else [] was different -- there I play games with using either side as context for the other. That doesn't seem applicable here, at least it seems harder since the general case may be arbitrarily complex. I think it would be possible if [] came out with some type other than List[None] so that the unification code (I think in join.py) could special-case it safely (it currently can't know whether the List[None] came from [] or from actually writing e.g. [None, None]).
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
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.
When trying to fix Mapping and MutableMapping definition in mypy, I got an error stating that it can't add a
List[None]to aList[Frame](orList[Constaint]), having these comments allow it to work.Not much related, shouldn't it be infered as a
List[Any]instead?