[icalendar] Use stricter pyright settings (#15159)

This commit is contained in:
Semyon Moroz
2025-12-21 14:48:55 +00:00
committed by GitHub
parent d8d989280c
commit fd7481c0da
7 changed files with 26 additions and 23 deletions
+2 -1
View File
@@ -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",
@@ -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__
+2 -2
View File
@@ -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: ...
+16 -9
View File
@@ -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]
+2 -1
View File
@@ -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: ...
+3 -3
View File
@@ -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:
@@ -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): ...