Skip to content

Experiment: revert datetime-date inheritance - #15136

Draft
m-aciek wants to merge 8 commits into
python:mainfrom
m-aciek:date-inheritance
Draft

m-aciek wants to merge 8 commits into
python:mainfrom
m-aciek:date-inheritance

Conversation

@m-aciek

@m-aciek m-aciek commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

I'll most probably open a Python forum discussion about it. I'm mostly interested in the mypy primer test.

Some context: glyph/DateType#16

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@m-aciek m-aciek changed the title Revert datetime-date inheritance Experiment: revert datetime-date inheritance Dec 15, 2025
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/_internal/schemas/validators.py:376: error: No overload variant of "__call__" of "_rrulestr" matches argument types "str", "datetime", "bool"  [call-overload]
+ src/prefect/_internal/schemas/validators.py:376: note: Possible overload variants:
+ src/prefect/_internal/schemas/validators.py:376: note:     def __call__(self, s: str, *, forceset: Literal[True], dtstart: date | None = ..., cache: bool | None = ..., unfold: bool = ..., compatible: bool = ..., ignoretz: bool = ..., tzids: Callable[[str], tzinfo] | Mapping[str, tzinfo] | None = ..., tzinfos: Mapping[str, tzinfo | int | str | None] | Callable[[str, int], tzinfo | int | str | None] | None = ...) -> rruleset
+ src/prefect/_internal/schemas/validators.py:376: note:     def __call__(self, s: str, *, compatible: Literal[True], dtstart: date | None = ..., cache: bool | None = ..., unfold: bool = ..., forceset: bool = ..., ignoretz: bool = ..., tzids: Callable[[str], tzinfo] | Mapping[str, tzinfo] | None = ..., tzinfos: Mapping[str, tzinfo | int | str | None] | Callable[[str, int], tzinfo | int | str | None] | None = ...) -> rruleset
+ src/prefect/_internal/schemas/validators.py:376: note:     def __call__(self, s: str, *, dtstart: date | None = ..., cache: bool | None = ..., unfold: bool = ..., forceset: bool = ..., compatible: bool = ..., ignoretz: bool = ..., tzids: Callable[[str], tzinfo] | Mapping[str, tzinfo] | None = ..., tzinfos: Mapping[str, tzinfo | int | str | None] | Callable[[str, int], tzinfo | int | str | None] | None = ...) -> rrule | rruleset

zulip (https://github.com/zulip/zulip)
+ zerver/lib/rate_limiter.py:451: error: Argument 1 to "timeuntil" has incompatible type "datetime"; expected "date"  [arg-type]
+ corporate/lib/stripe.py:2757: error: Unrecognized format specification "%B"  [str-format]
+ corporate/lib/stripe.py:2774: error: Unrecognized format specification "%B"  [str-format]
+ corporate/views/support.py:312: error: Argument 1 to "timesince" has incompatible type "datetime"; expected "date"  [arg-type]

core (https://github.com/home-assistant/core)
+ homeassistant/components/habitica/util.py:86: error: Argument "dtstart" to "rrule" has incompatible type "datetime"; expected "date | None"  [arg-type]
+ homeassistant/components/here_travel_time/coordinator.py:392: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date"  [arg-type]
+ homeassistant/components/input_datetime/__init__.py:396: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date"  [arg-type]
+ homeassistant/helpers/template/extensions/datetime.py:263: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date"  [arg-type]
+ homeassistant/components/google_travel_time/helpers.py:61: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date"  [arg-type]
+ homeassistant/components/radarr/coordinator.py:179: error: Unsupported operand types for >= ("datetime" and "date")  [operator]
+ homeassistant/components/radarr/coordinator.py:179: note: Left operand is of type "date | datetime"
+ homeassistant/components/radarr/coordinator.py:195: error: Unsupported operand types for >= ("datetime" and "date")  [operator]
+ homeassistant/components/radarr/coordinator.py:195: note: Left operand is of type "date | datetime"
+ homeassistant/components/evohome/storage.py:100: error: Argument 1 to "fromisoformat" of "datetime" has incompatible type "object"; expected "str"  [arg-type]
+ homeassistant/components/electric_kiwi/sensor.py:99: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date"  [arg-type]
+ homeassistant/components/electric_kiwi/sensor.py:105: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date"  [arg-type]
- homeassistant/components/evohome/storage.py:100: error: Argument 1 to "fromisoformat" of "date" has incompatible type "object"; expected "str"  [arg-type]
+ homeassistant/components/lamarzocco/calendar.py:101: error: Unsupported operand types for < ("date" and "datetime")  [operator]
+ homeassistant/components/lamarzocco/calendar.py:101: note: Left operand is of type "date | datetime"
+ homeassistant/components/lamarzocco/calendar.py:103: error: Unsupported operand types for > ("date" and "datetime")  [operator]
+ homeassistant/components/lamarzocco/calendar.py:103: note: Left operand is of type "date | datetime"
+ homeassistant/components/habitica/calendar.py:251: error: Unsupported operand types for < ("datetime" and "date")  [operator]
+ homeassistant/components/habitica/calendar.py:251: note: Left operand is of type "date | datetime"
+ homeassistant/components/habitica/calendar.py:372: error: Argument 2 to "start" of "HabiticaDailyRemindersCalendarEntity" has incompatible type "datetime"; expected "date"  [arg-type]
+ homeassistant/components/sonarr/calendar.py:68: error: Unsupported operand types for > ("date" and "datetime")  [operator]
+ homeassistant/components/sonarr/calendar.py:68: note: Left operand is of type "date | datetime"
+ homeassistant/components/workday/binary_sensor.py:77: error: Argument 1 to "date_is_workday" of "BaseWorkdayEntity" has incompatible type "datetime"; expected "date"  [arg-type]
+ homeassistant/components/workday/calendar.py:95: error: Unsupported operand types for >= ("datetime" and "date")  [operator]
+ homeassistant/components/workday/calendar.py:95: note: Left operand is of type "date | datetime"
+ homeassistant/components/workday/calendar.py:105: error: Unsupported operand types for <= ("date" and "datetime")  [operator]
+ homeassistant/components/workday/calendar.py:105: note: Right operand is of type "date | datetime"
+ homeassistant/components/workday/calendar.py:105: error: Unsupported operand types for <= ("datetime" and "date")  [operator]
+ homeassistant/components/workday/calendar.py:105: note: Left operand is of type "date | datetime"

django-stubs (https://github.com/typeddjango/django-stubs)
+ django-stubs/db/models/fields/__init__.pyi:592: error: Incompatible types in assignment (expression has type "str | datetime | date | Combinable", base class "DateField" defined the type as "str | date | Combinable")  [assignment]
+ django-stubs/db/models/fields/__init__.pyi:593: error: Incompatible types in assignment (expression has type "datetime", base class "DateField" defined the type as "date")  [assignment]
+ django-stubs/db/models/fields/__init__.pyi:594: error: Incompatible types in assignment (expression has type "str | datetime", base class "DateField" defined the type as "str | date")  [assignment]

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_libs/tslibs/offsets.pyi:52: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/offsets.pyi:64: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/offsets.pyi:77: error: Unused "type: ignore" comment  [unused-ignore]
+ tests/test_timefuncs.py:110: error: Expression is of type "Timedelta", not "timedelta"  [assert-type]
+ tests/test_timefuncs.py:111: error: Expression is of type "Timedelta", not "timedelta"  [assert-type]
+ tests/test_timefuncs.py:1575: error: Argument 1 to "to_datetime" has incompatible type "list[datetime]"; expected "Sequence[float | date] | list[str] | tuple[float | str | date, ...] | ndarray[tuple[Any, ...], dtype[datetime64[Any]]] | ndarray[tuple[Any, ...], dtype[str_]] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | ndarray[tuple[Any, ...], dtype[floating[Any]]] | Index[Any] | ExtensionArray"  [arg-type]
+ tests/test_timefuncs.py:1611: error: Argument 1 to "to_datetime" has incompatible type "tuple[datetime, datetime, datetime]"; expected "Sequence[float | date] | list[str] | tuple[float | str | date, ...] | ndarray[tuple[Any, ...], dtype[datetime64[Any]]] | ndarray[tuple[Any, ...], dtype[str_]] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | ndarray[tuple[Any, ...], dtype[floating[Any]]] | Index[Any] | ExtensionArray"  [arg-type]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/_libs/tslibs/timestamps.pyi:164: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/_libs/tslibs/timestamps.pyi:165: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/_libs/tslibs/timestamps.pyi:166: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/_libs/tslibs/timestamps.pyi:167: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/io/stata.py:366: error: No overload variant of "to_datetime" matches argument type "datetime"  [call-overload]
+ pandas/io/stata.py:366: note: Possible overload variants:
+ pandas/io/stata.py:366: note:     def to_datetime(arg: float | str | date | datetime64[Any], errors: Literal['raise', 'coerce'] = ..., dayfirst: bool = ..., yearfirst: bool = ..., utc: bool = ..., format: str | None = ..., exact: bool = ..., unit: str | None = ..., origin: Any = ..., cache: bool = ...) -> Timestamp
+ pandas/io/stata.py:366: note:     def to_datetime(arg: Series | FulldatetimeDict | DataFrame, errors: Literal['raise', 'coerce'] = ..., dayfirst: bool = ..., yearfirst: bool = ..., utc: bool = ..., format: str | None = ..., exact: bool = ..., unit: str | None = ..., origin: Any = ..., cache: bool = ...) -> Series
+ pandas/io/stata.py:366: note:     def to_datetime(arg: list[Any] | tuple[Any, ...] | Index | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]], errors: Literal['raise', 'coerce'] = ..., dayfirst: bool = ..., yearfirst: bool = ..., utc: bool = ..., format: str | None = ..., exact: bool = ..., unit: str | None = ..., origin: Any = ..., cache: bool = ...) -> DatetimeIndex
+ pandas/core/tools/datetimes.py:834: error: Overloaded function implementation cannot produce return type of signature 1  [misc]

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/datatypes/core.py:1125: error: Overloaded function signatures 7 and 8 overlap with incompatible return types  [overload-overlap]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/i18n.py: note: In function "babel_format_date":
+ sphinx/util/i18n.py:240:26: error: Argument 1 to "__call__" of "DateFormatter" has incompatible type "datetime"; expected "date | None"  [arg-type]
+ sphinx/util/i18n.py:240:26: error: Argument 1 to "__call__" of "DatetimeFormatter" has incompatible type "datetime"; expected "date | time | float | None"  [arg-type]
+ sphinx/util/i18n.py:249:26: error: Argument 1 to "__call__" of "DateFormatter" has incompatible type "datetime"; expected "date | None"  [arg-type]
+ sphinx/util/i18n.py:249:26: error: Argument 1 to "__call__" of "DatetimeFormatter" has incompatible type "datetime"; expected "date | time | float | None"  [arg-type]

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/http.py:1186: error: Argument 1 to "formatdate" has incompatible type "datetime | int | float | None"; expected "float | None"  [arg-type]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant