-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Overly Strict type definition for busday_offset #20746
Copy link
Copy link
Closed
Description
Describe the issue:
The type definition for busday_offset is overly strict and does not accept arguments of types "date", "int", "str"
Reproduce the code example:
Run mypy on:
import datetime as dt
import numpy as np
print(np.busday_offset(dt.date.today(), -3, roll="forward"))Error message:
$ mypy test.py
test.py:5: error: No overload variant of "busday_offset" matches argument types "date", "int", "str"
test.py:5: note: Possible overload variants:
test.py:5: note: def busday_offset(dates: datetime64, offsets: Union[Union[Union[bool, bool_], int, integer[Any]], timedelta64], roll: Literal['raise'] = ..., weekmask: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]] = ..., holidays: Optional[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = ..., busdaycal: Optional[busdaycalendar] = ..., out: None = ...) -> datetime64
test.py:5: note: def busday_offset(dates: Union[_SupportsArray[dtype[datetime64]], Sequence[_SupportsArray[dtype[datetime64]]], Sequence[Sequence[_SupportsArray[dtype[datetime64]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[datetime64]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[datetime64]]]]]]], offsets: Union[_SupportsArray[dtype[Union[bool_, integer[Any], timedelta64]]], _NestedSequence[_SupportsArray[dtype[Union[bool_, integer[Any], timedelta64]]]], bool, int, _NestedSequence[Union[bool, int]]], roll: Literal['raise'] = ..., weekmask: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]] = ..., holidays: Optional[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = ..., busdaycal: Optional[busdaycalendar] = ..., out: None = ...) -> ndarray[Any, dtype[datetime64]]
test.py:5: note: <4 more similar overloads not shown, out of 6 total overloads>
Found 1 error in 1 file (checked 1 source file)NumPy/Python version information:
1.22.0 3.9.7 (default, Sep 9 2021, 13:29:35)
[Clang 12.0.5 (clang-1205.0.22.9)]
Reactions are currently unavailable