-
-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Labels
Description
Describe the bug
to_timedelta uses a list of a union argument type.
This will raise false positive errors when passing a list of a single type because list is invariant.
To Reproduce
import pandas as pd
pd.to_timedelta(["1 day"])produces:
error: Argument 1 to "to_timedelta" has incompatible type "list[str]"; expected "Union[Sequence[Union[float, timedelta]], list[Union[str, float, timedelta]], tuple[Union[str, float, timedelta], ...], range, Union[ExtensionArray, ndarray[Any, Any]], Index[Any]]" [arg-type]
note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
note: Consider using "Sequence" instead, which is covariant
Please complete the following information:
- OS: Win
- OS Version 10
- python 3.9.7
- version of type checker mypy 1.8.0
- version of installed
pandas-stubs2.2.2.240603