diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 3c694d5353c0..ead367e93a33 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -49,7 +49,8 @@ "stubs/html5lib", "stubs/httplib2", "stubs/hvac", - "stubs/icalendar", + "stubs/icalendar/icalendar/prop.pyi", + "stubs/icalendar/icalendar/timezone/provider.pyi", "stubs/jsonschema", "stubs/jwcrypto", "stubs/ldap3", diff --git a/stubs/icalendar/@tests/stubtest_allowlist.txt b/stubs/icalendar/@tests/stubtest_allowlist.txt index 086f94be4c60..960867805a39 100644 --- a/stubs/icalendar/@tests/stubtest_allowlist.txt +++ b/stubs/icalendar/@tests/stubtest_allowlist.txt @@ -6,9 +6,7 @@ icalendar\.tests(\..*)? # Methods that use `int` to mean `bool`. icalendar.Component.get_inline -icalendar.Component.set_inline icalendar.cal.Component.get_inline -icalendar.cal.Component.set_inline # Stubtest gets confused by multiple inheritance. icalendar.prop.vSkip.__new__ diff --git a/stubs/icalendar/icalendar/alarms.pyi b/stubs/icalendar/icalendar/alarms.pyi index d62f5641d024..975a413369ce 100644 --- a/stubs/icalendar/icalendar/alarms.pyi +++ b/stubs/icalendar/icalendar/alarms.pyi @@ -21,7 +21,7 @@ class AlarmTime: acknowledged_until: datetime.datetime | None = None, snoozed_until: datetime.datetime | None = None, parent: Parent | None = None, - ): ... + ) -> None: ... @property def acknowledged(self) -> datetime.datetime | None: ... @property @@ -33,7 +33,7 @@ class AlarmTime: def trigger(self) -> datetime.date: ... class Alarms: - def __init__(self, component: Alarm | Event | Todo | None = None): ... + def __init__(self, component: Alarm | Event | Todo | None = None) -> None: ... def add_component(self, component: Alarm | Parent) -> None: ... def set_parent(self, parent: Parent) -> None: ... def add_alarm(self, alarm: Alarm) -> None: ... diff --git a/stubs/icalendar/icalendar/cal.pyi b/stubs/icalendar/icalendar/cal.pyi index db452d1f59ea..84aef3cffa5a 100644 --- a/stubs/icalendar/icalendar/cal.pyi +++ b/stubs/icalendar/icalendar/cal.pyi @@ -1,16 +1,19 @@ import datetime from _typeshed import Incomplete, SupportsItems -from collections.abc import Callable -from typing import Any, ClassVar, Final, Literal, NamedTuple, overload +from collections.abc import Callable, Iterable +from typing import Any, ClassVar, Final, Literal, NamedTuple, TypeVar, overload from typing_extensions import Self from .alarms import Alarms from .caselessdict import CaselessDict from .error import IncompleteComponent as IncompleteComponent from .parser import Contentline, Contentlines -from .prop import TypesFactory, vRecur +from .parser_tools import ICAL_TYPE +from .prop import TypesFactory, _vType, vRecur from .timezone.tzp import TZP +_D = TypeVar("_D") + __all__ = [ "Alarm", "Calendar", @@ -32,7 +35,8 @@ __all__ = [ def get_example(component_directory: str, example_name: str) -> bytes: ... class ComponentFactory(CaselessDict[Incomplete]): - def __init__(self, *args, **kwargs) -> None: ... + # Inherit complex __init__ from CaselessDict<-dict. + ... INLINE: CaselessDict[int] @@ -47,7 +51,7 @@ class Component(CaselessDict[Incomplete]): subcomponents: list[Incomplete] errors: list[str] - def __init__(self, *args, **kwargs) -> None: ... + # Inherit complex __init__ from CaselessDict<-dict. def __bool__(self) -> bool: ... __nonzero__ = __bool__ def is_empty(self) -> bool: ... @@ -59,9 +63,12 @@ class Component(CaselessDict[Incomplete]): def add( self, name: str, value: Any, parameters: SupportsItems[str, str | None] | None = None, encode: Literal[True] = True ) -> None: ... - def decoded(self, name, default=[]): ... - def get_inline(self, name, decode: bool = True): ... - def set_inline(self, name, values, encode: bool = True) -> None: ... + def decoded(self, name: str, default: _D = ...) -> Incomplete | _D: ... + def get_inline(self, name: str, decode: bool = True) -> list[Incomplete]: ... + @overload + def set_inline(self, name: str, values: Iterable[str], encode: Literal[False] = ...) -> None: ... + @overload + def set_inline(self, name: str, values: Iterable[Incomplete], encode: Literal[True] = True) -> None: ... def add_component(self, component: Component) -> None: ... def walk(self, name: str | None = None, select: Callable[[Component], bool] = ...) -> list[Component]: ... def property_items(self, recursive: bool = True, sorted: bool = True) -> list[tuple[str, object]]: ... @@ -71,7 +78,7 @@ class Component(CaselessDict[Incomplete]): @overload @classmethod def from_ical(cls, st: str, multiple: Literal[True]) -> list[Component]: ... # or any of its subclasses - def content_line(self, name: str, value, sorted: bool = True) -> Contentline: ... + def content_line(self, name: str, value: _vType | ICAL_TYPE, sorted: bool = True) -> Contentline: ... def content_lines(self, sorted: bool = True) -> Contentlines: ... def to_ical(self, sorted: bool = True) -> bytes: ... def __eq__(self, other: Component) -> bool: ... # type: ignore[override] diff --git a/stubs/icalendar/icalendar/parser.pyi b/stubs/icalendar/icalendar/parser.pyi index e1aaea27f9e1..c6924bb646b3 100644 --- a/stubs/icalendar/icalendar/parser.pyi +++ b/stubs/icalendar/icalendar/parser.pyi @@ -7,6 +7,7 @@ from typing_extensions import Self from .caselessdict import CaselessDict from .parser_tools import ICAL_TYPE +from .prop import _vType __all__ = [ "Contentline", @@ -83,7 +84,7 @@ class Contentline(str): strict: bool def __new__(cls, value: str | bytes, strict: bool = False, encoding: str = "utf-8") -> Self: ... @classmethod - def from_parts(cls, name: ICAL_TYPE, params: Parameters, values, sorted: bool = True) -> Self: ... + def from_parts(cls, name: ICAL_TYPE, params: Parameters, values: _vType | ICAL_TYPE, sorted: bool = True) -> Self: ... def parts(self) -> tuple[str, Parameters, str]: ... @classmethod def from_ical(cls, ical: str | bytes, strict: bool = False) -> Self: ... diff --git a/stubs/icalendar/icalendar/prop.pyi b/stubs/icalendar/icalendar/prop.pyi index a3e0c389f32d..2675ebe82baf 100644 --- a/stubs/icalendar/icalendar/prop.pyi +++ b/stubs/icalendar/icalendar/prop.pyi @@ -1,5 +1,5 @@ import datetime -from _typeshed import ConvertibleToFloat, ConvertibleToInt, SupportsKeysAndGetItem, Unused +from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, SupportsKeysAndGetItem, Unused from collections.abc import Iterable, Iterator from enum import Enum from re import Pattern @@ -84,7 +84,7 @@ class vText(str): class vCalAddress(str): params: Parameters - def __new__(cls, value: ICAL_TYPE, encoding="utf-8", params: SupportsKeysAndGetItem[str, str] = {}) -> Self: ... + def __new__(cls, value: ICAL_TYPE, encoding: str = "utf-8", params: SupportsKeysAndGetItem[str, str] = {}) -> Self: ... def to_ical(self) -> bytes: ... @classmethod def from_ical(cls, ical: ICAL_TYPE) -> Self: ... @@ -127,7 +127,7 @@ class vDDDLists: def __init__(self, dt_list: Iterable[_AnyTimeType] | _AnyTimeType) -> None: ... def to_ical(self) -> bytes: ... @staticmethod - def from_ical(ical: str, timezone: str | datetime.timezone | None = None): ... + def from_ical(ical: str, timezone: str | datetime.timezone | None = None) -> list[Incomplete]: ... def __eq__(self, other: object) -> bool: ... class vCategory: diff --git a/stubs/icalendar/icalendar/timezone/zoneinfo.pyi b/stubs/icalendar/icalendar/timezone/zoneinfo.pyi index 2e6b6e938fe5..6891652c89ce 100644 --- a/stubs/icalendar/icalendar/timezone/zoneinfo.pyi +++ b/stubs/icalendar/icalendar/timezone/zoneinfo.pyi @@ -2,7 +2,7 @@ import datetime from typing import Final, Literal from zoneinfo import ZoneInfo -from dateutil.rrule import rrule, rruleset +from dateutil.rrule import rrule from ..cal import Timezone from ..prop import vRecur @@ -22,7 +22,3 @@ class ZONEINFO(TZProvider): def create_timezone(self, tz: Timezone) -> datetime.tzinfo: ... # type: ignore[override] def uses_pytz(self) -> Literal[False]: ... def uses_zoneinfo(self) -> Literal[True]: ... - -def pickle_tzicalvtz(tzicalvtz): ... -def pickle_rruleset_with_cache(rs: rruleset): ... -def unpickle_rruleset_with_cache(rrule, rdate, exrule, exdate, cache): ...