-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Experiment: revert datetime-date inheritance #15136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
m-aciek
wants to merge
7
commits into
python:main
Choose a base branch
from
m-aciek:date-inheritance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+35
−10
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: freqtrade (https://github.com/freqtrade/freqtrade)
+ freqtrade/exchange/binance_public_data.py:81: error: Argument 5 to "_download_archive_ohlcv" has incompatible type "datetime"; expected "date" [arg-type]
+ freqtrade/exchange/binance_public_data.py:81: error: Argument 6 to "_download_archive_ohlcv" has incompatible type "datetime"; expected "date" [arg-type]
+ freqtrade/exchange/binance_public_data.py:326: error: Argument 4 to "_download_archive_trades" has incompatible type "datetime"; expected "date" [arg-type]
+ freqtrade/exchange/binance_public_data.py:326: error: Argument 5 to "_download_archive_trades" has incompatible type "datetime"; expected "date" [arg-type]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "datetime" matches argument type "datetime64[date | int | None]" [operator]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "datetime64" matches argument type "datetime" [operator]
- freqtrade/optimize/optimize_reports/optimize_reports.py:215: error: Argument 5 to "_generate_result_line" has incompatible type "str | bytes | date | timedelta | datetime64[date | int | None] | <8 more items>"; expected "str | list[str]" [arg-type]
+ freqtrade/optimize/optimize_reports/optimize_reports.py:215: error: Argument 5 to "_generate_result_line" has incompatible type "str | bytes | date | datetime | timedelta | <9 more items>"; expected "str | list[str]" [arg-type]
- freqtrade/strategy/strategy_helper.py:102: error: Invalid index type "tuple[str | bytes | date | timedelta | datetime64[date | int | None] | <7 more items>, str]" for "_AtIndexerFrame"; expected type "tuple[int | str | str_ | Timestamp | tuple[str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any], ...] | Callable[[DataFrame], Never], int | str | str_ | tuple[str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any], ...]]" [index]
+ freqtrade/strategy/strategy_helper.py:102: error: Invalid index type "tuple[str | bytes | date | datetime | timedelta | <8 more items>, str]" for "_AtIndexerFrame"; expected type "tuple[int | str | str_ | Timestamp | tuple[str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any], ...] | Callable[[DataFrame], Never], int | str | str_ | tuple[str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any], ...]]" [index]
+ freqtrade/strategy/strategy_helper.py:107: error: No overload variant of "__sub__" of "datetime" matches argument type "int" [operator]
+ freqtrade/strategy/strategy_helper.py:107: note: def __sub__(self, datetime, /) -> timedelta
+ freqtrade/strategy/strategy_helper.py:107: note: def __sub__(self, timedelta, /) -> datetime
- freqtrade/strategy/strategy_helper.py:107: note: Left operand is of type "str | bytes | date | timedelta | datetime64[date | int | None] | <7 more items>"
+ freqtrade/strategy/strategy_helper.py:107: note: Left operand is of type "str | bytes | date | datetime | timedelta | <8 more items>"
+ freqtrade/strategy/strategy_helper.py:108: error: No overload variant of "__sub__" of "datetime" matches argument type "int" [operator]
+ freqtrade/strategy/strategy_helper.py:108: note: def __sub__(self, datetime, /) -> timedelta
+ freqtrade/strategy/strategy_helper.py:108: note: def __sub__(self, timedelta, /) -> datetime
- freqtrade/strategy/strategy_helper.py:108: note: Left operand is of type "str | bytes | date | timedelta | datetime64[date | int | None] | <7 more items>"
+ freqtrade/strategy/strategy_helper.py:108: note: Left operand is of type "str | bytes | date | datetime | timedelta | <8 more items>"
- freqtrade/rpc/telegram.py:408: error: Value of type "Series[Any] | str | bytes | date | timedelta | <8 more items>" is not indexable [index]
+ freqtrade/rpc/telegram.py:408: error: Value of type "Series[Any] | str | bytes | date | datetime | <9 more items>" is not indexable [index]
- freqtrade/rpc/telegram.py:409: error: Value of type "Series[Any] | str | bytes | date | timedelta | <8 more items>" is not indexable [index]
+ freqtrade/rpc/telegram.py:409: error: Value of type "Series[Any] | str | bytes | date | datetime | <9 more items>" is not indexable [index]
- freqtrade/optimize/backtesting.py:426: error: Argument 1 to "__call__" of "_UFunc_Nin1_Nout1" has incompatible type "str | bytes | date | timedelta | datetime64[date | int | None] | <8 more items>"; expected "complex | str | bytes | generic[Any]" [arg-type]
+ freqtrade/optimize/backtesting.py:426: error: Argument 1 to "__call__" of "_UFunc_Nin1_Nout1" has incompatible type "str | bytes | date | datetime | timedelta | <9 more items>"; expected "complex | str | bytes | generic[Any]" [arg-type]
- freqtrade/optimize/backtesting.py:428: error: Incompatible return value type (got "tuple[str | bytes | date | timedelta | datetime64[date | int | None] | <8 more items>, Any]", expected "tuple[float | None, int]") [return-value]
+ freqtrade/optimize/backtesting.py:428: error: Incompatible return value type (got "tuple[str | bytes | date | datetime | timedelta | <9 more items>, Any]", expected "tuple[float | None, int]") [return-value]
- freqtrade/optimize/backtesting.py:507: error: List item 0 has incompatible type "int | None"; expected "str | bytes | date | timedelta | datetime64[date | int | None] | <8 more items>" [list-item]
+ freqtrade/optimize/backtesting.py:507: error: List item 0 has incompatible type "int | None"; expected "str | bytes | date | datetime | timedelta | <9 more items>" [list-item]
- freqtrade/templates/FreqaiExampleStrategy.py:287: error: Value of type "Series[Any] | str | bytes | date | timedelta | <8 more items>" is not indexable [index]
+ freqtrade/templates/FreqaiExampleStrategy.py:287: error: Value of type "Series[Any] | str | bytes | date | datetime | <9 more items>" is not indexable [index]
- freqtrade/templates/FreqaiExampleStrategy.py:290: error: Value of type "Series[Any] | str | bytes | date | timedelta | <8 more items>" is not indexable [index]
+ freqtrade/templates/FreqaiExampleStrategy.py:290: error: Value of type "Series[Any] | str | bytes | date | datetime | <9 more items>" is not indexable [index]
spark (https://github.com/apache/spark)
- python/pyspark/pandas/generic.py:2683: error: Argument 1 to "tuple" has incompatible type "DataFrame"; expected "Iterable[int | float | str | bytes | Decimal | date]" [arg-type]
+ python/pyspark/pandas/generic.py:2683: error: Argument 1 to "tuple" has incompatible type "DataFrame"; expected "Iterable[int | float | str | bytes | Decimal | date | datetime]" [arg-type]
- python/pyspark/pandas/generic.py:2683: note: def __iter__(self) -> Iterator[int | float | str | bytes | Decimal | date]
+ python/pyspark/pandas/generic.py:2683: note: def __iter__(self) -> Iterator[int | float | str | bytes | Decimal | date | datetime]
- python/pyspark/pandas/generic.py:3088: error: Incompatible return value type (got "Series[Any] | pandas.core.frame.DataFrame | str | bytes | date | <9 more items>", expected "int | float | bool | str | bytes | Decimal | date | datetime | None | pyspark.pandas.frame.DataFrame[Any] | Series[Any]") [return-value]
+ python/pyspark/pandas/generic.py:3088: error: Incompatible return value type (got "Series[Any] | pandas.core.frame.DataFrame | str | bytes | date | <10 more items>", expected "int | float | bool | str | bytes | Decimal | date | datetime | None | pyspark.pandas.frame.DataFrame[Any] | Series[Any]") [return-value]
- python/pyspark/pandas/indexes/base.py:2244: error: Incompatible return value type (got "str | bytes | date | timedelta | datetime64[date | int | None] | <7 more items>", expected "int | float | bool | str | bytes | Decimal | date | datetime | None") [return-value]
+ python/pyspark/pandas/indexes/base.py:2244: error: Incompatible return value type (got "str | bytes | date | datetime | timedelta | <8 more items>", expected "int | float | bool | str | bytes | Decimal | date | datetime | None") [return-value]
bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/util/serialization.py:213:29: error: Unsupported operand types for - ("datetime64[date | int | None]" and "datetime64[datetime]") [operator]
+ src/bokeh/util/serialization.py:213:29: note: Left operand is of type "datetime64[Any] | datetime64[date | int | None]"
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]
core (https://github.com/home-assistant/core)
+ homeassistant/components/radarr/coordinator.py:174: error: Unsupported operand types for >= ("datetime" and "date") [operator]
+ homeassistant/components/radarr/coordinator.py:174: note: Left operand is of type "date | datetime"
+ homeassistant/components/radarr/coordinator.py:190: error: Unsupported operand types for >= ("datetime" and "date") [operator]
+ homeassistant/components/radarr/coordinator.py:190: note: Left operand is of type "date | datetime"
+ homeassistant/components/here_travel_time/coordinator.py:391: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date" [arg-type]
+ homeassistant/components/habitica/util.py:88: error: Argument "dtstart" to "rrule" has incompatible type "datetime"; expected "date | None" [arg-type]
- homeassistant/components/evohome/storage.py:98: error: Argument 1 to "fromisoformat" of "date" has incompatible type "object"; expected "str" [arg-type]
+ homeassistant/components/evohome/storage.py:98: error: Argument 1 to "fromisoformat" of "datetime" has incompatible type "object"; expected "str" [arg-type]
+ homeassistant/helpers/template/extensions/datetime.py:257: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date" [arg-type]
+ homeassistant/components/season/sensor.py:108: error: Argument 1 to "get_season" has incompatible type "datetime"; expected "date" [arg-type]
+ homeassistant/components/google_travel_time/sensor.py:84: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date" [arg-type]
+ homeassistant/components/electric_kiwi/sensor.py:100: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date" [arg-type]
+ homeassistant/components/electric_kiwi/sensor.py:106: error: Argument 1 to "combine" of "datetime" has incompatible type "datetime"; expected "date" [arg-type]
+ homeassistant/components/workday/calendar.py:96: error: Unsupported operand types for >= ("datetime" and "date") [operator]
+ homeassistant/components/workday/calendar.py:96: 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"
+ homeassistant/components/workday/binary_sensor.py:94: error: Argument 1 to "date_is_workday" of "BaseWorkdayEntity" has incompatible type "datetime"; expected "date" [arg-type]
+ homeassistant/components/lamarzocco/calendar.py:98: error: Unsupported operand types for < ("date" and "datetime") [operator]
+ homeassistant/components/lamarzocco/calendar.py:98: note: Left operand is of type "date | datetime"
+ homeassistant/components/lamarzocco/calendar.py:100: error: Unsupported operand types for > ("date" and "datetime") [operator]
+ homeassistant/components/lamarzocco/calendar.py:100: note: Left operand is of type "date | datetime"
+ homeassistant/components/habitica/calendar.py:247: error: Unsupported operand types for < ("datetime" and "date") [operator]
+ homeassistant/components/habitica/calendar.py:247: note: Left operand is of type "date | datetime"
+ homeassistant/components/habitica/calendar.py:366: error: Argument 2 to "start" of "HabiticaDailyRemindersCalendarEntity" has incompatible type "datetime"; expected "date" [arg-type]
django-stubs (https://github.com/typeddjango/django-stubs)
+ django-stubs/db/models/fields/__init__.pyi:543: 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:544: 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:545: error: Incompatible types in assignment (expression has type "str | datetime", base class "DateField" defined the type as "str | date") [assignment]
zulip (https://github.com/zulip/zulip)
+ corporate/lib/stripe.py:2548: error: Unrecognized format specification "%B" [str-format]
+ corporate/lib/stripe.py:2565: error: Unrecognized format specification "%B" [str-format]
+ corporate/views/support.py:305: error: Argument 1 to "timesince" has incompatible type "datetime"; expected "date" [arg-type]
ibis (https://github.com/ibis-project/ibis)
- ibis/expr/datatypes/core.py:62: error: Overloaded function signatures 7 and 8 overlap with incompatible return types [overload-overlap]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/_libs/tslibs/timestamps.pyi:149: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/_libs/tslibs/timestamps.pyi:150: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/_libs/tslibs/timestamps.pyi:151: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/_libs/tslibs/timestamps.pyi:152: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/io/stata.py:357: error: No overload variant of "to_datetime" matches argument type "datetime" [call-overload]
+ pandas/io/stata.py:357: note: Possible overload variants:
+ pandas/io/stata.py:357: note: def to_datetime(arg: float | str | date | datetime64[date | int | None], 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:357: 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:357: 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:677: error: Overloaded function implementation cannot produce return type of signature 1 [misc]
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_libs/tslibs/offsets.pyi:48: error: Unused "type: ignore" comment [unused-ignore]
+ pandas-stubs/_libs/tslibs/offsets.pyi:60: error: Unused "type: ignore" comment [unused-ignore]
+ pandas-stubs/_libs/tslibs/offsets.pyi:71: error: Unused "type: ignore" comment [unused-ignore]
+ tests/test_timefuncs.py:111: error: Expression is of type "Timedelta", not "timedelta" [assert-type]
+ tests/test_timefuncs.py:114: error: Expression is of type "Timedelta", not "timedelta" [assert-type]
+ tests/test_timefuncs.py:1398: 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[date | int | None]]] | ndarray[tuple[Any, ...], dtype[str_]] | ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]] | Index[Any] | ExtensionArray" [arg-type]
+ tests/test_timefuncs.py:1434: 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[date | int | None]]] | ndarray[tuple[Any, ...], dtype[str_]] | ndarray[tuple[Any, ...], dtype[signedinteger[_64Bit]]] | Index[Any] | ExtensionArray" [arg-type]
+ tests/test_pandas.py:506: error: Argument 1 to "notna" has incompatible type "datetime64[datetime]"; expected "NaTType | NAType | None" [arg-type]
+ tests/test_pandas.py:507: error: Argument 1 to "isna" has incompatible type "datetime64[datetime]"; expected "str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any] | NaTType | NAType | None" [arg-type]
+ tests/series/test_sub.py:234: error: Expression is of type "Any", not "Series[Timedelta]" [assert-type]
+ tests/series/test_sub.py:234: error: Unsupported operand types for - ("Series[Any]" and "datetime64[datetime]") [operator]
+ tests/series/test_sub.py:246: error: Expression is of type "Any", not "Series[Any]" [assert-type]
+ tests/series/test_sub.py:246: error: No overload variant of "__sub__" of "datetime64" matches argument type "Series[Any]" [operator]
+ tests/series/test_sub.py:246: note: Possible overload variants:
+ tests/series/test_sub.py:246: note: def __sub__(self, int | integer[Any] | numpy.bool[builtins.bool], /) -> datetime64[datetime]
+ tests/series/test_sub.py:246: note: def __sub__(self, datetime, /) -> timedelta
+ tests/series/test_sub.py:246: note: def __sub__(self, timedelta64[int], /) -> datetime64[int]
+ tests/series/test_sub.py:246: note: def __sub__(self, timedelta64[timedelta], /) -> datetime64[datetime]
+ tests/series/test_sub.py:246: note: def __sub__(self, datetime64[int], /) -> timedelta64[int]
+ tests/series/test_sub.py:252: error: Expression is of type "Any", not "Series[Any]" [assert-type]
+ tests/series/test_sub.py:252: error: No overload variant of "__sub__" of "datetime64" matches argument type "Series[Any]" [operator]
+ tests/series/test_sub.py:252: note: Possible overload variants:
+ tests/series/test_sub.py:252: note: def __sub__(self, int | integer[Any] | numpy.bool[builtins.bool], /) -> datetime64[datetime]
+ tests/series/test_sub.py:252: note: def __sub__(self, datetime, /) -> timedelta
+ tests/series/test_sub.py:252: note: def __sub__(self, timedelta64[int], /) -> datetime64[int]
+ tests/series/test_sub.py:252: note: def __sub__(self, timedelta64[timedelta], /) -> datetime64[datetime]
+ tests/series/test_sub.py:252: note: def __sub__(self, datetime64[int], /) -> timedelta64[int]
+ tests/series/test_sub.py:260: error: Expression is of type "Series[int]", not "Series[Timedelta]" [assert-type]
+ tests/series/test_sub.py:260: error: Argument 1 to "sub" of "Series" has incompatible type "datetime64[datetime]"; expected "Just[int] | Sequence[Just[int]] | ndarray[tuple[Any, ...], dtype[integer[Any]]] | Index[int] | Series[int]" [arg-type]
+ tests/series/test_sub.py:271: error: Argument 1 to "rsub" of "Series" has incompatible type "datetime64[datetime]"; expected "complex | datetime | Sequence[datetime] | datetime64[date | int | None] | ndarray[tuple[Any, ...], dtype[datetime64[date | int | None]]] | <10 more items>" [arg-type]
+ tests/series/test_sub.py:273: error: Argument 1 to "rsub" of "Series" has incompatible type "datetime64[datetime]"; expected "complex | datetime | Sequence[datetime] | datetime64[date | int | None] | ndarray[tuple[Any, ...], dtype[datetime64[date | int | None]]] | <10 more items>" [arg-type]
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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