-
-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Labels
mypy bugRequires mypy to fix a bugRequires mypy to fix a bug
Description
Describe the bug
Not sure if this is the correct project to report this issue; it may look like a mypy issue, but I could not reproduce it with any example that was not from pandas-stubs.
Mypy is not complaining about a wrong pd.Series when passing directly in a function.
To Reproduce
Example not displaying error:
from __future__ import annotations
import pandas as pd
def some_function(param: pd.Series[str]) -> pd.Series[float]:
return param.astype(float)
some_function(param=pd.Series([1.0, 1.0, 1.0], dtype=float)mypy doesn't complain
>>>mypy test.py
Success: no issues found in 1 source file
But, if this value is kept in a variable, the error is shown.
from __future__ import annotations
import pandas as pd
def some_function(param: pd.Series[str]) -> pd.Series[float]:
return param.astype(float)
some_value = pd.Series([1.0, 1.0, 1.0], dtype=float)
some_function(some_value)>>> mypy test.py
/tmp/test.py:11: error: Argument 1 to "some_function" has incompatible type "Series[float]"; expected "Series[str]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Please complete the following information:
-
OS: MacOS M1
-
OS Version Ventura 13.0
-
python version: 3.9.12 (Can see the same issue on Python 3.10)
-
version of type checker: mypy 0.982 (compiled: yes)
-
version of installed
pandas-stubs
pandas==1.5.1
pandas-stubs==1.5.1.221024
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
mypy bugRequires mypy to fix a bugRequires mypy to fix a bug