Type hints for `Arrow.interval` should show `Arrow` as possible type for `start` and `end` arguments
- Dominant language
- Python
- Stars
- 9.1k
- Forks
- 784
- PR merge metrics
- No merged PRs in 30d
Description
## Issue Description
Currently, footprint for `Arrow.interval` is:
```py
def interval(
cls,
frame: _T_FRAMES,
start: dt_datetime,
end: dt_datetime,
interval: int = 1,
tz: Optional[TZ_EXPR] = None,
bounds: _BOUNDS = "[)",
exact: bool = False,
) -> Iterable[Tuple["Arrow", "Arrow"]]:
```
Despite the fact that `start` and `end` arguments have type `dt_datetime` (which is `datetime.datetime`) however, both of them accept `Arrow` objects, which, looking down the line, makes sense, as the only properties of these arguments that are used are shared between `Arrow` and `dt_datetime` and (see `fromdatetime` method).
Thus, i believe it would make sense to change type hints for both arguments to the union of `Arrow` and `dt_datetime`:
```py
def interval(
cls,
frame: _T_FRAMES,
start: "Arrow" | dt_datetime,
end: "Arrow" | dt_datetime,
interval: int = 1,
tz: Optional[TZ_EXPR] = None,
bounds: _BOUNDS = "[)",
exact: bool = False,
) -> Iterable[Tuple["Arrow", "Arrow"]]:
```
## System Info
- 🖥 **OS name and version**: Windows 24H2 26100.3476
- 🐍 **Python version**: 3.10.11
- 🏹 **Arrow version**: 1.3.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Find the implementation and type annotation for Arrow.interval, then inspect any nearby tests covering interval inputs. Verify how Arrow and datetime values are accepted before updating the start and end annotations. Done means the public signature advertises both accepted types and the relevant tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100