Skip to content

Commit 39c5eab

Browse files
authored
[pyluach] Add stubs (#14640)
1 parent ba6bdc6 commit 39c5eab

File tree

7 files changed

+299
-0
lines changed

7 files changed

+299
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Module with no public API, for internal use only:
2+
pyluach.gematria

stubs/pyluach/METADATA.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version = "2.2.*"
2+
upstream_repository = "https://github.com/simlist/pyluach"

stubs/pyluach/pyluach/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Final
2+
3+
__version__: Final[str]

stubs/pyluach/pyluach/dates.pyi

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import abc
2+
import datetime
3+
from collections.abc import Generator
4+
from enum import Enum
5+
from typing import TypedDict, overload, type_check_only
6+
from typing_extensions import Self
7+
8+
@type_check_only
9+
class _DateDict(TypedDict):
10+
year: int
11+
month: int
12+
day: int
13+
14+
class Rounding(Enum):
15+
PREVIOUS_DAY = 1
16+
NEXT_DAY = 2
17+
EXCEPTION = 3
18+
19+
class BaseDate(abc.ABC, metaclass=abc.ABCMeta):
20+
@property
21+
@abc.abstractmethod
22+
def jd(self) -> float: ...
23+
@abc.abstractmethod
24+
def to_heb(self) -> HebrewDate: ...
25+
def __hash__(self) -> int: ...
26+
def __add__(self, other: float) -> BaseDate: ...
27+
@overload
28+
def __sub__(self, other: float) -> BaseDate: ...
29+
@overload
30+
def __sub__(self, other: BaseDate) -> int: ...
31+
def __eq__(self, other: object) -> bool: ...
32+
def __ne__(self, other: object) -> bool: ...
33+
def __lt__(self, other: object) -> bool: ...
34+
def __gt__(self, other: object) -> bool: ...
35+
def __le__(self, other: object) -> bool: ...
36+
def __ge__(self, other: object) -> bool: ...
37+
def weekday(self) -> int: ...
38+
def isoweekday(self) -> int: ...
39+
def shabbos(self) -> Self: ...
40+
def fast_day(self, hebrew: bool = False) -> str | None: ...
41+
def festival(
42+
self, israel: bool = False, hebrew: bool = False, include_working_days: bool = True, prefix_day: bool = False
43+
) -> str | None: ...
44+
def holiday(self, israel: bool = False, hebrew: bool = False, prefix_day: bool = False) -> str | None: ...
45+
46+
class CalendarDateMixin:
47+
year: int
48+
month: int
49+
day: int
50+
def __init__(self, year: int, month: int, day: int, jd: float | None = None) -> None: ...
51+
def __iter__(self) -> Generator[int]: ...
52+
def tuple(self) -> tuple[int, int, int]: ...
53+
def dict(self) -> _DateDict: ...
54+
def replace(self, year: int | None = None, month: int | None = None, day: int | None = None) -> Self: ...
55+
56+
class JulianDay(BaseDate):
57+
day: float
58+
def __init__(self, day: float) -> None: ...
59+
@property
60+
def jd(self) -> float: ...
61+
@staticmethod
62+
def from_pydate(pydate: datetime.date) -> JulianDay: ...
63+
@staticmethod
64+
def today() -> JulianDay: ...
65+
def to_greg(self) -> GregorianDate: ...
66+
def to_heb(self) -> HebrewDate: ...
67+
def to_pydate(self) -> datetime.date: ...
68+
69+
class GregorianDate(BaseDate, CalendarDateMixin):
70+
def __init__(self, year: int, month: int, day: int, jd: float | None = None) -> None: ...
71+
def __format__(self, fmt: str) -> str: ...
72+
def strftime(self, fmt: str) -> str: ...
73+
@property
74+
def jd(self) -> float: ...
75+
@classmethod
76+
def from_pydate(cls, pydate: datetime.date) -> Self: ...
77+
@staticmethod
78+
def today() -> GregorianDate: ...
79+
def is_leap(self) -> bool: ...
80+
def to_jd(self) -> JulianDay: ...
81+
def to_heb(self) -> HebrewDate: ...
82+
def to_pydate(self) -> datetime.date: ...
83+
84+
class HebrewDate(BaseDate, CalendarDateMixin):
85+
def __init__(self, year: int, month: int, day: int, jd: float | None = None) -> None: ...
86+
def __format__(self, fmt: str) -> str: ...
87+
@property
88+
def jd(self) -> float: ...
89+
@staticmethod
90+
def from_pydate(pydate: datetime.date) -> HebrewDate: ...
91+
@staticmethod
92+
def today() -> HebrewDate: ...
93+
def to_jd(self) -> JulianDay: ...
94+
def to_greg(self) -> GregorianDate: ...
95+
def to_pydate(self) -> datetime.date: ...
96+
def to_heb(self) -> HebrewDate: ...
97+
def month_name(self, hebrew: bool = False) -> str: ...
98+
def hebrew_day(self, withgershayim: bool = True) -> str: ...
99+
def hebrew_year(self, thousands: bool = False, withgershayim: bool = True) -> str: ...
100+
def hebrew_date_string(self, thousands: bool = False) -> str: ...
101+
def add(
102+
self, years: int = 0, months: int = 0, days: int = 0, adar1: bool | None = False, rounding: Rounding = Rounding.NEXT_DAY
103+
) -> HebrewDate: ...
104+
def subtract(
105+
self, years: int = 0, months: int = 0, days: int = 0, adar1: bool | None = False, rounding: Rounding = Rounding.NEXT_DAY
106+
) -> HebrewDate: ...

stubs/pyluach/pyluach/hebrewcal.pyi

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
import calendar
2+
import datetime
3+
from collections.abc import Generator
4+
from typing import Literal, TypedDict, overload, type_check_only
5+
from typing_extensions import Self
6+
7+
from .dates import BaseDate, HebrewDate
8+
9+
@type_check_only
10+
class _MoladDict(TypedDict):
11+
weekday: int
12+
hours: int
13+
parts: int
14+
15+
@type_check_only
16+
class _MoladAnnouncementDict(TypedDict):
17+
weekday: int
18+
hour: int
19+
minutes: int
20+
parts: int
21+
22+
class IllegalMonthError(ValueError):
23+
month: int
24+
def __init__(self, month: int) -> None: ...
25+
26+
class IllegalWeekdayError(ValueError):
27+
weekday: int
28+
def __init__(self, weekday: int) -> None: ...
29+
30+
class Year:
31+
year: int
32+
leap: bool
33+
def __init__(self, year: int) -> None: ...
34+
def __len__(self) -> int: ...
35+
def __eq__(self, other: object) -> bool: ...
36+
def __add__(self, other: int) -> Year: ...
37+
@overload
38+
def __sub__(self, other: int) -> Year: ...
39+
@overload
40+
def __sub__(self, other: Year) -> int: ...
41+
def __gt__(self, other: Year) -> bool: ...
42+
def __ge__(self, other: Year) -> bool: ...
43+
def __lt__(self, other: Year) -> bool: ...
44+
def __le__(self, other: Year) -> bool: ...
45+
def __iter__(self) -> Generator[int]: ...
46+
def monthscount(self) -> Literal[12, 13]: ...
47+
def itermonths(self) -> Generator[Month]: ...
48+
def iterdays(self) -> Generator[int]: ...
49+
def iterdates(self) -> Generator[HebrewDate]: ...
50+
@classmethod
51+
def from_date(cls, date: BaseDate) -> Self: ...
52+
@classmethod
53+
def from_pydate(cls, pydate: datetime.date) -> Self: ...
54+
def year_string(self, thousands: bool = False) -> str: ...
55+
56+
class Month:
57+
year: int
58+
month: int
59+
def __init__(self, year: int, month: int) -> None: ...
60+
def __len__(self) -> int: ...
61+
def __iter__(self) -> Generator[int]: ...
62+
def __eq__(self, other: object) -> bool: ...
63+
def __add__(self, other: int) -> Month: ...
64+
@overload
65+
def __sub__(self, other: int) -> Month: ...
66+
@overload
67+
def __sub__(self, other: Month) -> int: ...
68+
def __gt__(self, other: Month) -> bool: ...
69+
def __ge__(self, other: Month) -> bool: ...
70+
def __lt__(self, other: Month) -> bool: ...
71+
def __le__(self, other: Month) -> bool: ...
72+
@classmethod
73+
def from_date(cls, date: BaseDate) -> Month: ...
74+
@classmethod
75+
def from_pydate(cls, pydate: datetime.date) -> Month: ...
76+
def month_name(self, hebrew: bool = False) -> str: ...
77+
def month_string(self, thousands: bool = False) -> str: ...
78+
def starting_weekday(self) -> int: ...
79+
def iterdates(self) -> Generator[HebrewDate]: ...
80+
def molad(self) -> _MoladDict: ...
81+
def molad_announcement(self) -> _MoladAnnouncementDict: ...
82+
83+
def to_hebrew_numeral(num: int, thousands: bool = False, withgershayim: bool = True) -> str: ...
84+
85+
class HebrewCalendar(calendar.Calendar):
86+
hebrewnumerals: bool
87+
hebrewweekdays: bool
88+
hebrewmonths: bool
89+
hebrewyear: bool
90+
def __init__(
91+
self,
92+
firstweekday: int = 1,
93+
hebrewnumerals: bool = True,
94+
hebrewweekdays: bool = False,
95+
hebrewmonths: bool = False,
96+
hebrewyear: bool = False,
97+
) -> None: ...
98+
@property
99+
def firstweekday(self) -> int: ...
100+
@firstweekday.setter
101+
def firstweekday(self, thefirstweekday: int) -> None: ...
102+
def iterweekdays(self) -> Generator[int]: ...
103+
def itermonthdates(self, year: int, month: int) -> Generator[HebrewDate]: ... # type: ignore[override]
104+
def itermonthdays(self, year: int, month: int) -> Generator[int]: ...
105+
def itermonthdays2(self, year: int, month: int) -> Generator[tuple[int, int]]: ...
106+
def itermonthdays3(self, year: int, month: int) -> Generator[tuple[int, int, int]]: ...
107+
def itermonthdays4(self, year: int, month: int) -> Generator[tuple[int, int, int, int]]: ...
108+
def yeardatescalendar(self, year: int, width: int = 3) -> list[list[list[list[HebrewDate]]]]: ... # type: ignore[override]
109+
def yeardays2calendar(self, year: int, width: int = 3) -> list[list[list[list[tuple[int, int]]]]]: ...
110+
def yeardayscalendar(self, year: int, width: int = 3) -> list[list[list[list[int]]]]: ...
111+
def monthdatescalendar(self, year: int, month: int) -> list[list[HebrewDate]]: ... # type: ignore[override]
112+
113+
class HebrewHTMLCalendar(HebrewCalendar, calendar.HTMLCalendar):
114+
rtl: bool
115+
def __init__(
116+
self,
117+
firstweekday: int = 1,
118+
hebrewnumerals: bool = True,
119+
hebrewweekdays: bool = False,
120+
hebrewmonths: bool = False,
121+
hebrewyear: bool = False,
122+
rtl: bool = False,
123+
) -> None: ...
124+
def formatday(self, day: int, weekday: int) -> str: ...
125+
def formatweekday(self, day: int) -> str: ...
126+
def formatyearnumber(self, theyear: int) -> int | str: ...
127+
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
128+
def formatmonth(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
129+
def formatyear(self, theyear: int, width: int = 3) -> str: ...
130+
131+
class HebrewTextCalendar(HebrewCalendar, calendar.TextCalendar):
132+
def formatday(self, day: int, weekday: int, width: int) -> str: ...
133+
def formatweekday(self, day: int, width: int) -> str: ...
134+
def formatmonthname(self, theyear: int, themonth: int, width: int = 0, withyear: bool = True) -> str: ...
135+
def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...
136+
137+
def fast_day(date: BaseDate, hebrew: bool = False) -> str | None: ...
138+
def festival(
139+
date: BaseDate, israel: bool = False, hebrew: bool = False, include_working_days: bool = True, prefix_day: bool = False
140+
) -> str | None: ...
141+
def holiday(date: BaseDate, israel: bool = False, hebrew: bool = False, prefix_day: bool = False) -> str | None: ...

stubs/pyluach/pyluach/parshios.pyi

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from collections import OrderedDict
2+
from collections.abc import Generator
3+
from typing import Final
4+
5+
from .dates import BaseDate, HebrewDate
6+
7+
PARSHIOS: Final[list[str]]
8+
PARSHIOS_HEBREW: Final[list[str]]
9+
10+
def getparsha(date: BaseDate, israel: bool = False) -> list[int] | None: ...
11+
def getparsha_string(date: BaseDate, israel: bool = False, hebrew: bool = False) -> str | None: ...
12+
def iterparshios(year: int, israel: bool = False) -> Generator[list[int] | None]: ...
13+
def parshatable(year: int, israel: bool = False) -> OrderedDict[HebrewDate, list[int] | None]: ...

stubs/pyluach/pyluach/utils.pyi

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from enum import Enum
2+
from typing import Final
3+
4+
class _Days(Enum):
5+
ROSH_HASHANA = "Rosh Hashana"
6+
YOM_KIPPUR = "Yom Kippur"
7+
SUCCOS = "Succos"
8+
SHMINI_ATZERES = "Shmini Atzeres"
9+
SIMCHAS_TORAH = "Simchas Torah"
10+
CHANUKA = "Chanuka"
11+
TU_BSHVAT = "Tu B'shvat"
12+
PURIM_KATAN = "Purim Katan"
13+
PURIM = "Purim"
14+
SHUSHAN_PURIM = "Shushan Purim"
15+
PESACH = "Pesach"
16+
PESACH_SHENI = "Pesach Sheni"
17+
LAG_BAOMER = "Lag Ba'omer"
18+
SHAVUOS = "Shavuos"
19+
TU_BAV = "Tu B'av"
20+
TZOM_GEDALIA = "Tzom Gedalia"
21+
TENTH_OF_TEVES = "10 of Teves"
22+
TAANIS_ESTHER = "Taanis Esther"
23+
SEVENTEENTH_OF_TAMUZ = "17 of Tamuz"
24+
NINTH_OF_AV = "9 of Av"
25+
26+
MONTH_NAMES: Final[list[str]]
27+
MONTH_NAMES_HEBREW: Final[list[str]]
28+
FAST_DAYS: Final[list[str]]
29+
FAST_DAYS_HEBREW: Final[list[str]]
30+
FESTIVALS: Final[list[str]]
31+
FESTIVALS_HEBREW: Final[list[str]]
32+
WEEKDAYS: Final[dict[int, str]]

0 commit comments

Comments
 (0)