Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

It seems that the new mypy doesn't type the load results as before. #132

Closed
ltworf opened this issue Jun 13, 2020 · 8 comments
Closed

It seems that the new mypy doesn't type the load results as before. #132

ltworf opened this issue Jun 13, 2020 · 8 comments
Labels
mypy Concerns mypy

Comments

@ltworf
Copy link
Owner

ltworf commented Jun 13, 2020

Investigate and possibly fix.

@ltworf
Copy link
Owner Author

ltworf commented Jun 14, 2020

python/mypy#8946

Seems mypy decided to change behaviour…

@ltworf
Copy link
Owner Author

ltworf commented Jun 14, 2020

from typing import *
T = TypeVar('T')

def create(t: Type[T]) -> T:
    ...

reveal_type(create(int))
reveal_type(create(str))
reveal_type(create(List[int]))
reveal_type(create(Dict[int, int]))
reveal_type(create(Tuple[int]))
reveal_type(create(Union[int,str]))
reveal_type(create(Optional[int]))

It actually never worked!

test.py:7: note: Revealed type is 'builtins.int*'
test.py:8: note: Revealed type is 'builtins.str*'
test.py:9: note: Revealed type is 'builtins.list*[builtins.int*]'
test.py:10: note: Revealed type is 'builtins.dict*[builtins.int*, builtins.int*]'
test.py:11: note: Revealed type is 'Any'
test.py:12: note: Revealed type is 'Any'
test.py:13: note: Revealed type is 'Any'

@thomascellerier
Copy link
Contributor

Oh wow that breaks a lot of code.

@ltworf
Copy link
Owner Author

ltworf commented Jun 15, 2020

Well the new mypy rejects it completely instead of inferring Any, the old one only works for some types but not all, so the typechecking is not as strong as I thought.

@ltworf
Copy link
Owner Author

ltworf commented Jun 15, 2020

@thomascellerier I created an issue on mypy, let's see what they say about this. The good news is that if the top level is a dataclass or nameduple, it works :D

ltworf added a commit to ltworf/relational that referenced this issue Aug 24, 2020
ltworf added a commit to ltworf/relational that referenced this issue Aug 24, 2020
@ltworf
Copy link
Owner Author

ltworf commented Dec 6, 2020

Something seems to be moving python/mypy#9773

@ltworf
Copy link
Owner Author

ltworf commented Jan 28, 2021

@ltworf ltworf added the mypy Concerns mypy label Feb 3, 2021
@ltworf
Copy link
Owner Author

ltworf commented Dec 24, 2021

Closing, since it has nothing to do with typedload

@ltworf ltworf closed this as completed Dec 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
mypy Concerns mypy
Projects
None yet
Development

No branches or pull requests

2 participants