Skip to content

DatetimeLike annotation does not appear to work with dates #369

Closed
@gandhis1

Description

@gandhis1

This example is bdate_range, but I suspect this issue is spread more widely.

    import pandas as pd
    from typing import Optional
    from datetime import date
    a: Optional[date] = date(2022, 1, 1)
    b: Optional[date] = date(2022, 1, 10)
    dr = pd.bdate_range(a, b, freq="d")

error: Argument 2 to "bdate_range" has incompatible type "Optional[date]"; expected "Union[str, Union[datetime, datetime64, Timestamp], None]" [arg-type]

Tagging @bashtage as I think he's done some work around this recently. It seems to me that we may have made an assumption somewhere that date is a subset of datetime (it's actually the opposite).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions