Skip to content

Type hints for Arrow.interval should show Arrow as possible type for start and end arguments #1210

@HYBRID-BEING

Description

@HYBRID-BEING

Issue Description

Currently, footprint for Arrow.interval is:

    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:

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions