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
I'm posting this to here because PEP 482--484 didn't seem to mention either "scope" or del and this is probably an implementation detail.
Consider this example:
x=1delxx="a"
Mypy 0.470 raises an error for the above code, saying "Incompatible types in assignment (expression has type "str", variable has type "int")". But, shouldn't it be allowed because the xs before and after del are essentially different variables?
Compare it with
x=1x=Nonex="a"
which clearly is a type error (and mypy judges as such.)
Allowing the 1st pattern will open up the way to conveniently rewrite legacy codes like
# path: # type strpath=path.split(os.pathsep)
# path: # type List[str]
Mypy currently doesn't treat del as deleting a variable -- it rather treats it as deleting the value of a variable. We've discussed similar issues before -- this is basically a special case of #1174, so I'm closing this issue as duplicate. Feel free to add to the discussion in #1174 if you have new thoughts.
I'm posting this to here because PEP 482--484 didn't seem to mention either "scope" or
del
and this is probably an implementation detail.Consider this example:
Mypy 0.470 raises an error for the above code, saying "Incompatible types in assignment (expression has type "str", variable has type "int")". But, shouldn't it be allowed because the
x
s before and afterdel
are essentially different variables?Compare it with
which clearly is a type error (and mypy judges as such.)
Allowing the 1st pattern will open up the way to conveniently rewrite legacy codes like
(taken from
shutil.py
)I mean, we will be able to write
The text was updated successfully, but these errors were encountered: