From b5c7c2be01681700e4fb8262035e14bce076ac3a Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Sun, 1 Jun 2025 02:53:46 -0400 Subject: [PATCH 1/9] adding stub-file for dates module --- lib/matplotlib/dates.pyi | 202 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 lib/matplotlib/dates.pyi diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi new file mode 100644 index 000000000000..c5a76a836a81 --- /dev/null +++ b/lib/matplotlib/dates.pyi @@ -0,0 +1,202 @@ +import datetime +import numpy as np +from typing import Any, Callable, Dict, List, Optional, Sequence, Union + +from .ticker import Formatter, Locator +from .units import Axis, AxisInfo, ConversionInterface + + +def _get_tzinfo(tz: Optional[Union[str, datetime.tzinfo]] = ...) -> datetime.tzinfo: ... + +def _reset_epoch_test_example() -> None: ... + +def set_epoch(epoch: str) -> None: ... + +def get_epoch() -> str: ... + +def _dt64_to_ordinalf(d: Union[np.datetime64, np.ndarray]) -> Union[float, np.ndarray]: ... + +def _from_ordinalf(x: float, tz: Optional[Union[str, datetime.tzinfo]] = ...) -> datetime.datetime: ... + +def datestr2num(d: Union[str, Sequence[str]], default: Optional[datetime.datetime] = ...) -> Union[float, np.ndarray]: ... + +def date2num(d: Union[datetime.datetime, np.datetime64, Sequence[Union[datetime.datetime, np.datetime64]]]) -> Union[float, np.ndarray]: ... + +def num2date(x: Union[float, Sequence[float]], tz: Optional[Union[str, datetime.tzinfo]] = ...) -> Union[datetime.datetime, list[datetime.datetime]]: ... + +def num2timedelta(x: Union[float, Sequence[float]]) -> Union[datetime.timedelta, list[datetime.timedelta]]: ... + +def drange(dstart: datetime.datetime, dend: datetime.datetime, delta: datetime.timedelta) -> np.ndarray: ... + +def _wrap_in_tex(text: str) -> str: ... + +class DateFormatter(Formatter): + tz: Optional[Union[str, datetime.tzinfo]] + fmt: str + _usetex: Optional[bool] + + def __init__(self, fmt: str, tz: Optional[Union[str, datetime.tzinfo]] = None, *, usetex: Optional[bool] = None) -> None: ... + def __call__(self, x: float, pos: int = 0) -> str: ... + def set_tzinfo(self, tz: Optional[Union[str, datetime.tzinfo]]) -> None: ... + +class ConciseDateFormatter(Formatter): + _locator: Locator + _tz: Optional[Union[str, datetime.tzinfo]] + formats: List[str] + zero_formats: List[str] + offset_formats: List[str] + offset_string: str + show_offset: bool + _usetex: Optional[bool] + + def __init__(self, locator: Locator, + tz: Optional[Union[str, datetime.tzinfo]] = None, + formats: Optional[Sequence[str]] = None, + offset_formats: Optional[Sequence[str]] = None, + zero_formats: Optional[Sequence[str]] = None, + show_offset: bool = True, + *, usetex: Optional[bool] = None) -> None: ... + def __call__(self, x: float, pos: Optional[int] = None) -> List[str]: ... + def format_ticks(self, values: Sequence[float]) -> List[str]: ... + def get_offset(self) -> str: ... + def format_data_short(self, value: float) -> str: ... + +class AutoDateFormatter(Formatter): + _locator: Locator + _tz: Optional[Union[str, datetime.tzinfo]] + defaultfmt: str + _formatter: DateFormatter + _usetex: Optional[bool] + scaled: dict + + def __init__(self, locator: Locator, + tz: Optional[Union[str, datetime.tzinfo]] = None, + defaultfmt: str = '%Y-%m-%d', + *, usetex: Optional[bool] = None) -> None: ... + def _set_locator(self, locator: Locator) -> None: ... + def __call__(self, x: float, pos: Optional[int] = None) -> str: ... + +class rrulewrapper: + def __init__(self, freq: int, tzinfo: Optional[datetime.tzinfo] = None, **kwargs: Any) -> None: ... + def set(self, **kwargs: Any) -> None: ... + def _update_rrule(self, **kwargs: Any) -> None: ... + def _attach_tzinfo(self, dt: datetime, tzinfo: datetime.tzinfo) -> datetime: ... + def _aware_return_wrapper(self, f: Callable[..., Any], returns_list: bool = False) -> Callable[..., Any]: ... + def __getattr__(self, name: str) -> Any: ... + def __setstate__(self, state: dict) -> None: ... + +class DateLocator(Locator): + hms0d: dict[str, int] + + def __init__(self, tz: Optional[Any] = None) -> None: ... + def set_tzinfo(self, tz: Optional[Any]) -> None: ... + def datalim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... + def viewlim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... + def _get_unit(self) -> float: ... + def _get_interval(self) -> int: ... + def nonsingular(self, vmin: float, vmax: float) -> tuple[float, float]: ... + +class RRuleLocator(DateLocator): + def __init__(self, o: rrulewrapper, tz: Optional[Any] = None) -> None: ... + def __call__(self) -> List[float]: ... + def tick_values(self, vmin: datetime, vmax: datetime) -> List[float]: ... + def _create_rrule(self, vmin: datetime, vmax: datetime) -> tuple[datetime.datetime, datetime.datetime]: ... + def _get_unit(self) -> float: ... + @staticmethod + def get_unit_generic(freq: int) -> float: ... + def _get_interval(self) -> int: ... + +class AutoDateLocator(DateLocator): + def __init__(self, tz: Optional[Union[str, datetime.tzinfo]] = None, minticks: int = 5, + maxticks: Optional[Union[int, Dict[int, int]]] = None, + interval_multiples: bool = True) -> None: ... + + def __call__(self) -> List[float]: ... + + def tick_values(self, vmin: float, vmax: float) -> List[float]: ... + + def nonsingular(self, vmin: float, vmax: float) -> tuple[float, float]: ... + + def _get_unit(self) -> float: ... + + def get_locator(self, dmin: datetime, dmax: datetime) -> RRuleLocator: ... + + +class YearLocator(RRuleLocator): + def __init__(self, base: int = 1, month: int = 1, day: int = 1, + tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + + def _create_rrule(self, vmin: datetime, vmax: datetime) -> tuple[datetime.datetime, datetime.datetime]: ... + + +class MonthLocator(RRuleLocator): + def __init__(self, bymonth: Optional[Union[int, List[int]]] = None, + bymonthday: int = 1, interval: int = 1, + tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + +class WeekdayLocator(RRuleLocator): + def __init__(self, byweekday: Union[int, List[int]] = 1, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + + +class DayLocator(RRuleLocator): + def __init__(self, bymonthday: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + + +class HourLocator(RRuleLocator): + def __init__(self, byhour: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + + +class MinuteLocator(RRuleLocator): + def __init__(self, byminute: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + + +class SecondLocator(RRuleLocator): + def __init__(self, bysecond: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + + +class MicrosecondLocator(DateLocator): + def __init__(self, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + + def set_axis(self, axis) -> None: ... + + def __call__(self) -> List[float]: ... + + def tick_values(self, vmin: datetime, vmax: datetime) -> np.ndarray: ... + + def _get_unit(self) -> float: ... + + def _get_interval(self) -> int: ... + +class DateConverter(ConversionInterface): + def __init__(self, *, interval_multiples: bool = True) -> None: ... + + def axisinfo(self, unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + + @staticmethod + def convert(value: Union[datetime.datetime, datetime.date, float, Sequence[Union[datetime.datetime, datetime.date, float]]], + unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... + + @staticmethod + def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float]]], + axis: Axis) -> Optional[datetime.tzinfo]: ... + + +class ConciseDateConverter(DateConverter): + def __init__(self, formats: Optional[List[str]] = None, zero_formats: Optional[List[str]] = None, + offset_formats: Optional[List[str]] = None, + show_offset: bool = True, *, interval_multiples: bool = True) -> None: ... + + def axisinfo(self, unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + +class _SwitchableDateConverter: + @staticmethod + def _get_converter() -> Union["ConciseDateConverter", "DateConverter"]: ... + + def axisinfo(self, unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + + def default_units(self, x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], + axis: Axis) -> Optional[datetime.tzinfo]: ... + + def convert(self, value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], + unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... + \ No newline at end of file From 3a7ac4145fe84de2c18a8d63ea1381423f8df241 Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Sun, 1 Jun 2025 03:35:52 -0400 Subject: [PATCH 2/9] import and type hint corrections --- lib/matplotlib/dates.pyi | 67 +++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index c5a76a836a81..e0125010db70 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -2,10 +2,14 @@ import datetime import numpy as np from typing import Any, Callable, Dict, List, Optional, Sequence, Union -from .ticker import Formatter, Locator -from .units import Axis, AxisInfo, ConversionInterface +from .axis import Axis +from .projections.polar import _AxisWrapper +from .ticker import _DummyAxis, Formatter, Locator +from .units import AxisInfo, ConversionInterface +# --- Global Functions --- + def _get_tzinfo(tz: Optional[Union[str, datetime.tzinfo]] = ...) -> datetime.tzinfo: ... def _reset_epoch_test_example() -> None: ... @@ -30,13 +34,15 @@ def drange(dstart: datetime.datetime, dend: datetime.datetime, delta: datetime.t def _wrap_in_tex(text: str) -> str: ... +# --- Formatter Classes --- + class DateFormatter(Formatter): tz: Optional[Union[str, datetime.tzinfo]] fmt: str _usetex: Optional[bool] def __init__(self, fmt: str, tz: Optional[Union[str, datetime.tzinfo]] = None, *, usetex: Optional[bool] = None) -> None: ... - def __call__(self, x: float, pos: int = 0) -> str: ... + def __call__(self, x: float, pos: Optional[int] = 0) -> str: ... def set_tzinfo(self, tz: Optional[Union[str, datetime.tzinfo]]) -> None: ... class ConciseDateFormatter(Formatter): @@ -56,7 +62,7 @@ class ConciseDateFormatter(Formatter): zero_formats: Optional[Sequence[str]] = None, show_offset: bool = True, *, usetex: Optional[bool] = None) -> None: ... - def __call__(self, x: float, pos: Optional[int] = None) -> List[str]: ... + def __call__(self, x: float, pos: Optional[int] = 0) -> str: ... def format_ticks(self, values: Sequence[float]) -> List[str]: ... def get_offset(self) -> str: ... def format_data_short(self, value: float) -> str: ... @@ -74,22 +80,25 @@ class AutoDateFormatter(Formatter): defaultfmt: str = '%Y-%m-%d', *, usetex: Optional[bool] = None) -> None: ... def _set_locator(self, locator: Locator) -> None: ... - def __call__(self, x: float, pos: Optional[int] = None) -> str: ... + def __call__(self, x: float, pos: Optional[int] = 0) -> str: ... +# --- rrulewrapper (assuming it's in rrule.py and this is its stub) --- class rrulewrapper: def __init__(self, freq: int, tzinfo: Optional[datetime.tzinfo] = None, **kwargs: Any) -> None: ... def set(self, **kwargs: Any) -> None: ... def _update_rrule(self, **kwargs: Any) -> None: ... - def _attach_tzinfo(self, dt: datetime, tzinfo: datetime.tzinfo) -> datetime: ... + def _attach_tzinfo(self, dt: datetime.datetime, tzinfo: datetime.tzinfo) -> datetime.datetime: ... def _aware_return_wrapper(self, f: Callable[..., Any], returns_list: bool = False) -> Callable[..., Any]: ... def __getattr__(self, name: str) -> Any: ... def __setstate__(self, state: dict) -> None: ... +# --- Locator Classes --- + class DateLocator(Locator): hms0d: dict[str, int] - def __init__(self, tz: Optional[Any] = None) -> None: ... - def set_tzinfo(self, tz: Optional[Any]) -> None: ... + def __init__(self, tz: Optional[datetime.tzinfo] = None) -> None: ... + def set_tzinfo(self, tz: Optional[datetime.tzinfo]) -> None: ... def datalim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... def viewlim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... def _get_unit(self) -> float: ... @@ -97,10 +106,10 @@ class DateLocator(Locator): def nonsingular(self, vmin: float, vmax: float) -> tuple[float, float]: ... class RRuleLocator(DateLocator): - def __init__(self, o: rrulewrapper, tz: Optional[Any] = None) -> None: ... + def __init__(self, o: rrulewrapper, tz: Optional[datetime.tzinfo] = None) -> None: ... def __call__(self) -> List[float]: ... - def tick_values(self, vmin: datetime, vmax: datetime) -> List[float]: ... - def _create_rrule(self, vmin: datetime, vmax: datetime) -> tuple[datetime.datetime, datetime.datetime]: ... + def tick_values(self, vmin: float, vmax: float) -> List[float]: ... + def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... def _get_unit(self) -> float: ... @staticmethod def get_unit_generic(freq: int) -> float: ... @@ -119,14 +128,14 @@ class AutoDateLocator(DateLocator): def _get_unit(self) -> float: ... - def get_locator(self, dmin: datetime, dmax: datetime) -> RRuleLocator: ... + def get_locator(self, dmin: datetime.datetime, dmax: datetime.datetime) -> RRuleLocator: ... class YearLocator(RRuleLocator): def __init__(self, base: int = 1, month: int = 1, day: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... - def _create_rrule(self, vmin: datetime, vmax: datetime) -> tuple[datetime.datetime, datetime.datetime]: ... + def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... class MonthLocator(RRuleLocator): @@ -157,27 +166,31 @@ class SecondLocator(RRuleLocator): class MicrosecondLocator(DateLocator): def __init__(self, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... - def set_axis(self, axis) -> None: ... + # Fix: Argument 1 incompatible with supertype TickHelper + def set_axis(self, axis: Union[Axis, _DummyAxis, _AxisWrapper, None]) -> None: ... def __call__(self) -> List[float]: ... - def tick_values(self, vmin: datetime, vmax: datetime) -> np.ndarray: ... + def tick_values(self, vmin: float, vmax: float) -> Sequence[float]: ... def _get_unit(self) -> float: ... def _get_interval(self) -> int: ... +# --- Converter Classes --- + class DateConverter(ConversionInterface): def __init__(self, *, interval_multiples: bool = True) -> None: ... - def axisinfo(self, unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + @staticmethod + def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... @staticmethod - def convert(value: Union[datetime.datetime, datetime.date, float, Sequence[Union[datetime.datetime, datetime.date, float]]], + def convert(value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... @staticmethod - def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float]]], + def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], axis: Axis) -> Optional[datetime.tzinfo]: ... @@ -186,17 +199,21 @@ class ConciseDateConverter(DateConverter): offset_formats: Optional[List[str]] = None, show_offset: bool = True, *, interval_multiples: bool = True) -> None: ... - def axisinfo(self, unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + @staticmethod + def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + class _SwitchableDateConverter: @staticmethod def _get_converter() -> Union["ConciseDateConverter", "DateConverter"]: ... - def axisinfo(self, unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + @staticmethod + def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... - def default_units(self, x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - axis: Axis) -> Optional[datetime.tzinfo]: ... + @staticmethod + def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], + axis: Axis) -> Optional[datetime.tzinfo]: ... - def convert(self, value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... - \ No newline at end of file + @staticmethod + def convert(value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], + unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... \ No newline at end of file From e485a7df1a8ccc5169abcc8799591c4b6e81ac1f Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Sun, 1 Jun 2025 03:46:45 -0400 Subject: [PATCH 3/9] adding a ruff test pass as well --- lib/matplotlib/dates.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index e0125010db70..1f8910c6eb33 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -212,8 +212,8 @@ class _SwitchableDateConverter: @staticmethod def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - axis: Axis) -> Optional[datetime.tzinfo]: ... + axis: Axis) -> Optional[datetime.tzinfo]: ... @staticmethod def convert(value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... \ No newline at end of file + unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... From aee2931891f420e04ffe481290881c3d8b455f7d Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Sun, 1 Jun 2025 04:16:12 -0400 Subject: [PATCH 4/9] passing the pyright test --- lib/matplotlib/dates.pyi | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index 1f8910c6eb33..850aac16a775 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -4,7 +4,7 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Union from .axis import Axis from .projections.polar import _AxisWrapper -from .ticker import _DummyAxis, Formatter, Locator +from .ticker import _DummyAxis, Formatter, Locator, TickHelper from .units import AxisInfo, ConversionInterface @@ -103,7 +103,7 @@ class DateLocator(Locator): def viewlim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... def _get_unit(self) -> float: ... def _get_interval(self) -> int: ... - def nonsingular(self, vmin: float, vmax: float) -> tuple[float, float]: ... + def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ... class RRuleLocator(DateLocator): def __init__(self, o: rrulewrapper, tz: Optional[datetime.tzinfo] = None) -> None: ... @@ -119,22 +119,16 @@ class AutoDateLocator(DateLocator): def __init__(self, tz: Optional[Union[str, datetime.tzinfo]] = None, minticks: int = 5, maxticks: Optional[Union[int, Dict[int, int]]] = None, interval_multiples: bool = True) -> None: ... - def __call__(self) -> List[float]: ... - def tick_values(self, vmin: float, vmax: float) -> List[float]: ... - - def nonsingular(self, vmin: float, vmax: float) -> tuple[float, float]: ... - + def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ... def _get_unit(self) -> float: ... - def get_locator(self, dmin: datetime.datetime, dmax: datetime.datetime) -> RRuleLocator: ... class YearLocator(RRuleLocator): def __init__(self, base: int = 1, month: int = 1, day: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... - def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... @@ -165,55 +159,42 @@ class SecondLocator(RRuleLocator): class MicrosecondLocator(DateLocator): def __init__(self, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... - - # Fix: Argument 1 incompatible with supertype TickHelper def set_axis(self, axis: Union[Axis, _DummyAxis, _AxisWrapper, None]) -> None: ... - def __call__(self) -> List[float]: ... - def tick_values(self, vmin: float, vmax: float) -> Sequence[float]: ... - def _get_unit(self) -> float: ... - def _get_interval(self) -> int: ... # --- Converter Classes --- class DateConverter(ConversionInterface): def __init__(self, *, interval_multiples: bool = True) -> None: ... - @staticmethod - def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... - + def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> None: ... @staticmethod - def convert(value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], + def convert(obj: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... - @staticmethod def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - axis: Axis) -> Optional[datetime.tzinfo]: ... + axis: Axis) -> None: ... class ConciseDateConverter(DateConverter): def __init__(self, formats: Optional[List[str]] = None, zero_formats: Optional[List[str]] = None, offset_formats: Optional[List[str]] = None, show_offset: bool = True, *, interval_multiples: bool = True) -> None: ... - @staticmethod - def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> None: ... class _SwitchableDateConverter: @staticmethod def _get_converter() -> Union["ConciseDateConverter", "DateConverter"]: ... - @staticmethod def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... - @staticmethod def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], axis: Axis) -> Optional[datetime.tzinfo]: ... - @staticmethod def convert(value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... From e75fe2b9c334eb42c6c214e5e239dff6c0842389 Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Sun, 1 Jun 2025 04:22:56 -0400 Subject: [PATCH 5/9] passing all the tests --- lib/matplotlib/dates.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index 850aac16a775..488d633dc400 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -4,7 +4,7 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Union from .axis import Axis from .projections.polar import _AxisWrapper -from .ticker import _DummyAxis, Formatter, Locator, TickHelper +from .ticker import _DummyAxis, Formatter, Locator from .units import AxisInfo, ConversionInterface From 8a0f20fff60e7a88f775eb8bfff1e76eaba9ef7b Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Tue, 3 Jun 2025 00:02:08 -0400 Subject: [PATCH 6/9] removing Optional and Union to remain consistent with other pyi files --- lib/matplotlib/dates.pyi | 110 +++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index 488d633dc400..a30c49ddf1df 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -1,6 +1,6 @@ import datetime import numpy as np -from typing import Any, Callable, Dict, List, Optional, Sequence, Union +from typing import Any, Callable, Dict, List, Sequence from .axis import Axis from .projections.polar import _AxisWrapper @@ -10,7 +10,7 @@ from .units import AxisInfo, ConversionInterface # --- Global Functions --- -def _get_tzinfo(tz: Optional[Union[str, datetime.tzinfo]] = ...) -> datetime.tzinfo: ... +def _get_tzinfo(tz: str | datetime.tzinfo | None = ...) -> datetime.tzinfo: ... def _reset_epoch_test_example() -> None: ... @@ -18,17 +18,17 @@ def set_epoch(epoch: str) -> None: ... def get_epoch() -> str: ... -def _dt64_to_ordinalf(d: Union[np.datetime64, np.ndarray]) -> Union[float, np.ndarray]: ... +def _dt64_to_ordinalf(d: np.datetime64 | np.ndarray) -> float | np.ndarray: ... -def _from_ordinalf(x: float, tz: Optional[Union[str, datetime.tzinfo]] = ...) -> datetime.datetime: ... +def _from_ordinalf(x: float, tz: str | datetime.tzinfo | None = ...) -> datetime.datetime: ... -def datestr2num(d: Union[str, Sequence[str]], default: Optional[datetime.datetime] = ...) -> Union[float, np.ndarray]: ... +def datestr2num(d: str | Sequence[str], default: datetime.datetime | None = ...) -> float | np.ndarray: ... -def date2num(d: Union[datetime.datetime, np.datetime64, Sequence[Union[datetime.datetime, np.datetime64]]]) -> Union[float, np.ndarray]: ... +def date2num(d: datetime.datetime | np.datetime64 | Sequence[datetime.datetime | np.datetime64]) -> float | np.ndarray: ... -def num2date(x: Union[float, Sequence[float]], tz: Optional[Union[str, datetime.tzinfo]] = ...) -> Union[datetime.datetime, list[datetime.datetime]]: ... +def num2date(x: float | Sequence[float], tz: str | datetime.tzinfo | None = ...) -> datetime.datetime | list[datetime.datetime]: ... -def num2timedelta(x: Union[float, Sequence[float]]) -> Union[datetime.timedelta, list[datetime.timedelta]]: ... +def num2timedelta(x: float | Sequence[float]) -> datetime.timedelta | list[datetime.timedelta]: ... def drange(dstart: datetime.datetime, dend: datetime.datetime, delta: datetime.timedelta) -> np.ndarray: ... @@ -37,54 +37,54 @@ def _wrap_in_tex(text: str) -> str: ... # --- Formatter Classes --- class DateFormatter(Formatter): - tz: Optional[Union[str, datetime.tzinfo]] + tz: str | datetime.tzinfo | None fmt: str - _usetex: Optional[bool] + _usetex: bool | None - def __init__(self, fmt: str, tz: Optional[Union[str, datetime.tzinfo]] = None, *, usetex: Optional[bool] = None) -> None: ... - def __call__(self, x: float, pos: Optional[int] = 0) -> str: ... - def set_tzinfo(self, tz: Optional[Union[str, datetime.tzinfo]]) -> None: ... + def __init__(self, fmt: str, tz: str | datetime.tzinfo | None = None, *, usetex: bool | None = None) -> None: ... + def __call__(self, x: float, pos: int | None = 0) -> str: ... + def set_tzinfo(self, tz: str | datetime.tzinfo | None) -> None: ... class ConciseDateFormatter(Formatter): _locator: Locator - _tz: Optional[Union[str, datetime.tzinfo]] + _tz: str | datetime.tzinfo | None formats: List[str] zero_formats: List[str] offset_formats: List[str] offset_string: str show_offset: bool - _usetex: Optional[bool] + _usetex: bool | None def __init__(self, locator: Locator, - tz: Optional[Union[str, datetime.tzinfo]] = None, - formats: Optional[Sequence[str]] = None, - offset_formats: Optional[Sequence[str]] = None, - zero_formats: Optional[Sequence[str]] = None, + tz: str | datetime.tzinfo | None = None, + formats: Sequence[str] | None = None, + offset_formats: Sequence[str] | None = None, + zero_formats: Sequence[str] | None = None, show_offset: bool = True, - *, usetex: Optional[bool] = None) -> None: ... - def __call__(self, x: float, pos: Optional[int] = 0) -> str: ... + *, usetex: bool | None = None) -> None: ... + def __call__(self, x: float, pos: int | None = 0) -> str: ... def format_ticks(self, values: Sequence[float]) -> List[str]: ... def get_offset(self) -> str: ... def format_data_short(self, value: float) -> str: ... class AutoDateFormatter(Formatter): _locator: Locator - _tz: Optional[Union[str, datetime.tzinfo]] + _tz: str | datetime.tzinfo | None defaultfmt: str _formatter: DateFormatter - _usetex: Optional[bool] + _usetex: bool | None scaled: dict def __init__(self, locator: Locator, - tz: Optional[Union[str, datetime.tzinfo]] = None, + tz: str | datetime.tzinfo | None = None, defaultfmt: str = '%Y-%m-%d', - *, usetex: Optional[bool] = None) -> None: ... + *, usetex: bool | None = None) -> None: ... def _set_locator(self, locator: Locator) -> None: ... - def __call__(self, x: float, pos: Optional[int] = 0) -> str: ... + def __call__(self, x: float, pos: int | None = 0) -> str: ... # --- rrulewrapper (assuming it's in rrule.py and this is its stub) --- class rrulewrapper: - def __init__(self, freq: int, tzinfo: Optional[datetime.tzinfo] = None, **kwargs: Any) -> None: ... + def __init__(self, freq: int, tzinfo: datetime.tzinfo | None = None, **kwargs: Any) -> None: ... def set(self, **kwargs: Any) -> None: ... def _update_rrule(self, **kwargs: Any) -> None: ... def _attach_tzinfo(self, dt: datetime.datetime, tzinfo: datetime.tzinfo) -> datetime.datetime: ... @@ -97,8 +97,8 @@ class rrulewrapper: class DateLocator(Locator): hms0d: dict[str, int] - def __init__(self, tz: Optional[datetime.tzinfo] = None) -> None: ... - def set_tzinfo(self, tz: Optional[datetime.tzinfo]) -> None: ... + def __init__(self, tz: datetime.tzinfo | None = None) -> None: ... + def set_tzinfo(self, tz: datetime.tzinfo | None) -> None: ... def datalim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... def viewlim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... def _get_unit(self) -> float: ... @@ -106,7 +106,7 @@ class DateLocator(Locator): def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ... class RRuleLocator(DateLocator): - def __init__(self, o: rrulewrapper, tz: Optional[datetime.tzinfo] = None) -> None: ... + def __init__(self, o: rrulewrapper, tz: datetime.tzinfo | None = None) -> None: ... def __call__(self) -> List[float]: ... def tick_values(self, vmin: float, vmax: float) -> List[float]: ... def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... @@ -116,8 +116,8 @@ class RRuleLocator(DateLocator): def _get_interval(self) -> int: ... class AutoDateLocator(DateLocator): - def __init__(self, tz: Optional[Union[str, datetime.tzinfo]] = None, minticks: int = 5, - maxticks: Optional[Union[int, Dict[int, int]]] = None, + def __init__(self, tz: str | datetime.tzinfo | None = None, minticks: int = 5, + maxticks: int | Dict[int, int] | None = None, interval_multiples: bool = True) -> None: ... def __call__(self) -> List[float]: ... def tick_values(self, vmin: float, vmax: float) -> List[float]: ... @@ -128,38 +128,38 @@ class AutoDateLocator(DateLocator): class YearLocator(RRuleLocator): def __init__(self, base: int = 1, month: int = 1, day: int = 1, - tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + tz: str | datetime.tzinfo | None = None) -> None: ... def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... class MonthLocator(RRuleLocator): - def __init__(self, bymonth: Optional[Union[int, List[int]]] = None, + def __init__(self, bymonth: int | List[int] | None = None, bymonthday: int = 1, interval: int = 1, - tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + tz: str | datetime.tzinfo | None = None) -> None: ... class WeekdayLocator(RRuleLocator): - def __init__(self, byweekday: Union[int, List[int]] = 1, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + def __init__(self, byweekday: int | List[int] = 1, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class DayLocator(RRuleLocator): - def __init__(self, bymonthday: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + def __init__(self, bymonthday: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class HourLocator(RRuleLocator): - def __init__(self, byhour: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + def __init__(self, byhour: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class MinuteLocator(RRuleLocator): - def __init__(self, byminute: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + def __init__(self, byminute: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class SecondLocator(RRuleLocator): - def __init__(self, bysecond: Optional[Union[int, List[int]]] = None, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... + def __init__(self, bysecond: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class MicrosecondLocator(DateLocator): - def __init__(self, interval: int = 1, tz: Optional[Union[str, datetime.tzinfo]] = None) -> None: ... - def set_axis(self, axis: Union[Axis, _DummyAxis, _AxisWrapper, None]) -> None: ... + def __init__(self, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def set_axis(self, axis: Axis | _DummyAxis | _AxisWrapper | None) -> None: ... def __call__(self) -> List[float]: ... def tick_values(self, vmin: float, vmax: float) -> Sequence[float]: ... def _get_unit(self) -> float: ... @@ -170,31 +170,31 @@ class MicrosecondLocator(DateLocator): class DateConverter(ConversionInterface): def __init__(self, *, interval_multiples: bool = True) -> None: ... @staticmethod - def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> None: ... + def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> None: ... @staticmethod - def convert(obj: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... + def convert(obj: datetime.datetime | datetime.date | float | np.datetime64 | Sequence[datetime.datetime | datetime.date | float | np.datetime64], + unit: datetime.tzinfo | None, axis: Axis) -> float | np.ndarray: ... @staticmethod - def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], + def default_units(x: datetime.datetime | datetime.date | float | np.ndarray | Sequence[datetime.datetime | datetime.date | float | np.datetime64], axis: Axis) -> None: ... class ConciseDateConverter(DateConverter): - def __init__(self, formats: Optional[List[str]] = None, zero_formats: Optional[List[str]] = None, - offset_formats: Optional[List[str]] = None, + def __init__(self, formats: List[str] | None = None, zero_formats: List[str] | None = None, + offset_formats: List[str] | None = None, show_offset: bool = True, *, interval_multiples: bool = True) -> None: ... @staticmethod - def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> None: ... + def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> None: ... class _SwitchableDateConverter: @staticmethod - def _get_converter() -> Union["ConciseDateConverter", "DateConverter"]: ... + def _get_converter() -> "ConciseDateConverter" | "DateConverter": ... @staticmethod - def axisinfo(unit: Optional[datetime.tzinfo], axis: Axis) -> AxisInfo: ... + def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> AxisInfo: ... @staticmethod - def default_units(x: Union[datetime.datetime, datetime.date, float, np.ndarray, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - axis: Axis) -> Optional[datetime.tzinfo]: ... + def default_units(x: datetime.datetime | datetime.date | float | np.ndarray | Sequence[datetime.datetime | datetime.date | float | np.datetime64], + axis: Axis) -> datetime.tzinfo | None: ... @staticmethod - def convert(value: Union[datetime.datetime, datetime.date, float, np.datetime64, Sequence[Union[datetime.datetime, datetime.date, float, np.datetime64]]], - unit: Optional[datetime.tzinfo], axis: Axis) -> Union[float, np.ndarray]: ... + def convert(value: datetime.datetime | datetime.date | float | np.datetime64 | Sequence[datetime.datetime | datetime.date | float | np.datetime64], + unit: datetime.tzinfo | None, axis: Axis) -> float | np.ndarray: ... From dde90a5f8670d7af5fbdbec016d1bfa40d903975 Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Mon, 9 Jun 2025 23:44:51 -0400 Subject: [PATCH 7/9] correcting overload for datestr2num --- lib/matplotlib/dates.pyi | 99 +++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 43 deletions(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index a30c49ddf1df..cd8b63a31802 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -1,6 +1,7 @@ import datetime +from typing import Any, Callable, overload, Sequence + import numpy as np -from typing import Any, Callable, Dict, List, Sequence from .axis import Axis from .projections.polar import _AxisWrapper @@ -18,17 +19,29 @@ def set_epoch(epoch: str) -> None: ... def get_epoch() -> str: ... -def _dt64_to_ordinalf(d: np.datetime64 | np.ndarray) -> float | np.ndarray: ... +def _dt64_to_ordinalf(d: np.ndarray) -> np.ndarray: ... def _from_ordinalf(x: float, tz: str | datetime.tzinfo | None = ...) -> datetime.datetime: ... -def datestr2num(d: str | Sequence[str], default: datetime.datetime | None = ...) -> float | np.ndarray: ... +@overload +def datestr2num(d: str, default: datetime.datetime | None = ...) -> float: ... +@overload +def datestr2num(d: list[str], default: datetime.datetime | None = ...) -> np.ndarray: ... -def date2num(d: datetime.datetime | np.datetime64 | Sequence[datetime.datetime | np.datetime64]) -> float | np.ndarray: ... +@overload +def date2num(d: datetime.datetime | np.datetime64) -> float: ... +@overload +def date2num(d: Sequence[datetime.datetime | np.datetime64]) -> np.ndarray: ... -def num2date(x: float | Sequence[float], tz: str | datetime.tzinfo | None = ...) -> datetime.datetime | list[datetime.datetime]: ... +@overload +def num2date(x: float, tz: str | datetime.tzinfo | None = ...) -> datetime.datetime: ... +@overload +def num2date(x: Sequence[float], tz: str | datetime.tzinfo | None = ...) -> list[datetime.datetime]: ... -def num2timedelta(x: float | Sequence[float]) -> datetime.timedelta | list[datetime.timedelta]: ... +@overload +def num2timedelta(x: float) -> datetime.timedelta: ... +@overload +def num2timedelta(x: Sequence[float]) -> list[datetime.timedelta]: ... def drange(dstart: datetime.datetime, dend: datetime.datetime, delta: datetime.timedelta) -> np.ndarray: ... @@ -37,33 +50,32 @@ def _wrap_in_tex(text: str) -> str: ... # --- Formatter Classes --- class DateFormatter(Formatter): - tz: str | datetime.tzinfo | None + tz: datetime.tzinfo fmt: str - _usetex: bool | None - def __init__(self, fmt: str, tz: str | datetime.tzinfo | None = None, *, usetex: bool | None = None) -> None: ... - def __call__(self, x: float, pos: int | None = 0) -> str: ... + def __init__(self, fmt: str, tz: str | datetime.tzinfo | None = ..., *, usetex: bool | None = ...) -> None: ... + def __call__(self, x: float, pos: int | None = ...) -> str: ... def set_tzinfo(self, tz: str | datetime.tzinfo | None) -> None: ... class ConciseDateFormatter(Formatter): _locator: Locator _tz: str | datetime.tzinfo | None - formats: List[str] - zero_formats: List[str] - offset_formats: List[str] + formats: list[str] + defaultfmt: str + zero_formats: list[str] + offset_formats: list[str] offset_string: str show_offset: bool - _usetex: bool | None def __init__(self, locator: Locator, - tz: str | datetime.tzinfo | None = None, - formats: Sequence[str] | None = None, - offset_formats: Sequence[str] | None = None, - zero_formats: Sequence[str] | None = None, - show_offset: bool = True, - *, usetex: bool | None = None) -> None: ... - def __call__(self, x: float, pos: int | None = 0) -> str: ... - def format_ticks(self, values: Sequence[float]) -> List[str]: ... + tz: str | datetime.tzinfo | None = ..., + formats: Sequence[str] | None = ..., + offset_formats: Sequence[str] | None = ..., + zero_formats: Sequence[str] | None = ..., + show_offset: bool = ..., + *, usetex: bool | None = ...) -> None: ... + def __call__(self, x: float, pos: int | None = ...) -> str: ... + def format_ticks(self, values: Sequence[float]) -> list[str]: ... def get_offset(self) -> str: ... def format_data_short(self, value: float) -> str: ... @@ -73,22 +85,23 @@ class AutoDateFormatter(Formatter): defaultfmt: str _formatter: DateFormatter _usetex: bool | None - scaled: dict + scaled: dict[float, str | Callable[[float, int | None], str]] def __init__(self, locator: Locator, - tz: str | datetime.tzinfo | None = None, - defaultfmt: str = '%Y-%m-%d', - *, usetex: bool | None = None) -> None: ... + tz: str | datetime.tzinfo | None = ..., + defaultfmt: str = ..., + *, usetex: bool | None = ...) -> None: ... def _set_locator(self, locator: Locator) -> None: ... - def __call__(self, x: float, pos: int | None = 0) -> str: ... + def __call__(self, x: float, pos: int | None = ...) -> str: ... + +# --- rrulewrapper --- -# --- rrulewrapper (assuming it's in rrule.py and this is its stub) --- class rrulewrapper: def __init__(self, freq: int, tzinfo: datetime.tzinfo | None = None, **kwargs: Any) -> None: ... def set(self, **kwargs: Any) -> None: ... def _update_rrule(self, **kwargs: Any) -> None: ... def _attach_tzinfo(self, dt: datetime.datetime, tzinfo: datetime.tzinfo) -> datetime.datetime: ... - def _aware_return_wrapper(self, f: Callable[..., Any], returns_list: bool = False) -> Callable[..., Any]: ... + def _aware_return_wrapper(self, f: Callable[..., Any], returns_list: bool = ...) -> Callable[..., Any]: ... def __getattr__(self, name: str) -> Any: ... def __setstate__(self, state: dict) -> None: ... @@ -107,8 +120,8 @@ class DateLocator(Locator): class RRuleLocator(DateLocator): def __init__(self, o: rrulewrapper, tz: datetime.tzinfo | None = None) -> None: ... - def __call__(self) -> List[float]: ... - def tick_values(self, vmin: float, vmax: float) -> List[float]: ... + def __call__(self) -> list[float]: ... + def tick_values(self, vmin: float, vmax: float) -> list[float]: ... def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... def _get_unit(self) -> float: ... @staticmethod @@ -117,10 +130,10 @@ class RRuleLocator(DateLocator): class AutoDateLocator(DateLocator): def __init__(self, tz: str | datetime.tzinfo | None = None, minticks: int = 5, - maxticks: int | Dict[int, int] | None = None, + maxticks: int | dict[int, int] | None = None, interval_multiples: bool = True) -> None: ... - def __call__(self) -> List[float]: ... - def tick_values(self, vmin: float, vmax: float) -> List[float]: ... + def __call__(self) -> list[float]: ... + def tick_values(self, vmin: float, vmax: float) -> list[float]: ... def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ... def _get_unit(self) -> float: ... def get_locator(self, dmin: datetime.datetime, dmax: datetime.datetime) -> RRuleLocator: ... @@ -133,34 +146,34 @@ class YearLocator(RRuleLocator): class MonthLocator(RRuleLocator): - def __init__(self, bymonth: int | List[int] | None = None, + def __init__(self, bymonth: int | list[int] | None = None, bymonthday: int = 1, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class WeekdayLocator(RRuleLocator): - def __init__(self, byweekday: int | List[int] = 1, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, byweekday: int | list[int] = 1, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class DayLocator(RRuleLocator): - def __init__(self, bymonthday: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, bymonthday: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class HourLocator(RRuleLocator): - def __init__(self, byhour: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, byhour: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class MinuteLocator(RRuleLocator): - def __init__(self, byminute: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, byminute: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class SecondLocator(RRuleLocator): - def __init__(self, bysecond: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, bysecond: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... class MicrosecondLocator(DateLocator): def __init__(self, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... def set_axis(self, axis: Axis | _DummyAxis | _AxisWrapper | None) -> None: ... - def __call__(self) -> List[float]: ... + def __call__(self) -> list[float]: ... def tick_values(self, vmin: float, vmax: float) -> Sequence[float]: ... def _get_unit(self) -> float: ... def _get_interval(self) -> int: ... @@ -180,8 +193,8 @@ class DateConverter(ConversionInterface): class ConciseDateConverter(DateConverter): - def __init__(self, formats: List[str] | None = None, zero_formats: List[str] | None = None, - offset_formats: List[str] | None = None, + def __init__(self, formats: list[str] | None = None, zero_formats: list[str] | None = None, + offset_formats: list[str] | None = None, show_offset: bool = True, *, interval_multiples: bool = True) -> None: ... @staticmethod def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> None: ... From 8f448fe2d5e080682bae6de732a0dda2e0f50453 Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Tue, 10 Jun 2025 07:52:56 -0400 Subject: [PATCH 8/9] correcting all the default values --- lib/matplotlib/dates.pyi | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index cd8b63a31802..abf1662881e8 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -97,7 +97,7 @@ class AutoDateFormatter(Formatter): # --- rrulewrapper --- class rrulewrapper: - def __init__(self, freq: int, tzinfo: datetime.tzinfo | None = None, **kwargs: Any) -> None: ... + def __init__(self, freq: int, tzinfo: datetime.tzinfo | None = ..., **kwargs: Any) -> None: ... def set(self, **kwargs: Any) -> None: ... def _update_rrule(self, **kwargs: Any) -> None: ... def _attach_tzinfo(self, dt: datetime.datetime, tzinfo: datetime.tzinfo) -> datetime.datetime: ... @@ -110,7 +110,7 @@ class rrulewrapper: class DateLocator(Locator): hms0d: dict[str, int] - def __init__(self, tz: datetime.tzinfo | None = None) -> None: ... + def __init__(self, tz: datetime.tzinfo | None = ...) -> None: ... def set_tzinfo(self, tz: datetime.tzinfo | None) -> None: ... def datalim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... def viewlim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ... @@ -119,7 +119,7 @@ class DateLocator(Locator): def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ... class RRuleLocator(DateLocator): - def __init__(self, o: rrulewrapper, tz: datetime.tzinfo | None = None) -> None: ... + def __init__(self, o: rrulewrapper, tz: datetime.tzinfo | None = ...) -> None: ... def __call__(self) -> list[float]: ... def tick_values(self, vmin: float, vmax: float) -> list[float]: ... def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... @@ -129,9 +129,9 @@ class RRuleLocator(DateLocator): def _get_interval(self) -> int: ... class AutoDateLocator(DateLocator): - def __init__(self, tz: str | datetime.tzinfo | None = None, minticks: int = 5, - maxticks: int | dict[int, int] | None = None, - interval_multiples: bool = True) -> None: ... + def __init__(self, tz: str | datetime.tzinfo | None = ..., minticks: int = ..., + maxticks: int | dict[int, int] | None = ..., + interval_multiples: bool = ...) -> None: ... def __call__(self) -> list[float]: ... def tick_values(self, vmin: float, vmax: float) -> list[float]: ... def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ... @@ -140,38 +140,38 @@ class AutoDateLocator(DateLocator): class YearLocator(RRuleLocator): - def __init__(self, base: int = 1, month: int = 1, day: int = 1, - tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, base: int = ..., month: int = ..., day: int = ..., + tz: str | datetime.tzinfo | None = ...) -> None: ... def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ... class MonthLocator(RRuleLocator): - def __init__(self, bymonth: int | list[int] | None = None, - bymonthday: int = 1, interval: int = 1, - tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, bymonth: int | list[int] | None = ..., + bymonthday: int = ..., interval: int = ..., + tz: str | datetime.tzinfo | None = ...) -> None: ... class WeekdayLocator(RRuleLocator): - def __init__(self, byweekday: int | list[int] = 1, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, byweekday: int | list[int] = ..., interval: int = ..., tz: str | datetime.tzinfo | None = ...) -> None: ... class DayLocator(RRuleLocator): - def __init__(self, bymonthday: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, bymonthday: int | list[int] | None = ..., interval: int = ..., tz: str | datetime.tzinfo | None = ...) -> None: ... class HourLocator(RRuleLocator): - def __init__(self, byhour: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, byhour: int | list[int] | None = ..., interval: int = ..., tz: str | datetime.tzinfo | None = ...) -> None: ... class MinuteLocator(RRuleLocator): - def __init__(self, byminute: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, byminute: int | list[int] | None = ..., interval: int = ..., tz: str | datetime.tzinfo | None = ...) -> None: ... class SecondLocator(RRuleLocator): - def __init__(self, bysecond: int | list[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, bysecond: int | list[int] | None = ..., interval: int = ..., tz: str | datetime.tzinfo | None = ...) -> None: ... class MicrosecondLocator(DateLocator): - def __init__(self, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ... + def __init__(self, interval: int = ..., tz: str | datetime.tzinfo | None = ...) -> None: ... def set_axis(self, axis: Axis | _DummyAxis | _AxisWrapper | None) -> None: ... def __call__(self) -> list[float]: ... def tick_values(self, vmin: float, vmax: float) -> Sequence[float]: ... @@ -181,7 +181,7 @@ class MicrosecondLocator(DateLocator): # --- Converter Classes --- class DateConverter(ConversionInterface): - def __init__(self, *, interval_multiples: bool = True) -> None: ... + def __init__(self, *, interval_multiples: bool = ...) -> None: ... @staticmethod def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> None: ... @staticmethod @@ -193,9 +193,9 @@ class DateConverter(ConversionInterface): class ConciseDateConverter(DateConverter): - def __init__(self, formats: list[str] | None = None, zero_formats: list[str] | None = None, - offset_formats: list[str] | None = None, - show_offset: bool = True, *, interval_multiples: bool = True) -> None: ... + def __init__(self, formats: list[str] | None = ..., zero_formats: list[str] | None = ..., + offset_formats: list[str] | None = ..., + show_offset: bool = ..., *, interval_multiples: bool = ...) -> None: ... @staticmethod def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> None: ... From 64270ee4825aa26b4c8b5b56fac8b1d866a1e6af Mon Sep 17 00:00:00 2001 From: Pooja Bandal Date: Wed, 18 Jun 2025 21:20:00 -0400 Subject: [PATCH 9/9] ruffdog newline at the end of file --- lib/matplotlib/dates.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/dates.pyi b/lib/matplotlib/dates.pyi index abf1662881e8..dd5617ea662e 100644 --- a/lib/matplotlib/dates.pyi +++ b/lib/matplotlib/dates.pyi @@ -8,7 +8,6 @@ from .projections.polar import _AxisWrapper from .ticker import _DummyAxis, Formatter, Locator from .units import AxisInfo, ConversionInterface - # --- Global Functions --- def _get_tzinfo(tz: str | datetime.tzinfo | None = ...) -> datetime.tzinfo: ...