Pyright is assigning Never type to a clearly defined type #2495
Unanswered
jmg-duarte
asked this question in
Q&A
Replies: 1 comment 4 replies
-
I tried to create a minimal self-contained example from your code above, but I'm not able to repro the problem. There must be something more involved. from typing import Any, Dict, List, Type, TypeVar
DataT = TypeVar("DataT", bool, int, float, str, List[Any], Dict[str, Any], None)
def read_data(path, type_: Type[DataT]) -> DataT:
...
class T:
def f(self, path, type_, data):
old_data = read_data(path=path, type_=type_)
if isinstance(data, list):
reveal_type(data) # list[Unknown]
if isinstance(old_data, list):
reveal_type(old_data) # list[Unknown]
new_data = old_data + data Any further thoughts or insights? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the following code snippet:
I don't get why
old_data
is attributed typeNever
.I was not able to create a minimal example and the original code is not public.
Beta Was this translation helpful? Give feedback.
All reactions