Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stubs/pyluach/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Module with no public API, for internal use only:
pyluach.gematria
2 changes: 2 additions & 0 deletions stubs/pyluach/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "2.2.*"
upstream_repository = "https://github.com/simlist/pyluach"
3 changes: 3 additions & 0 deletions stubs/pyluach/pyluach/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Final

__version__: Final[str]
106 changes: 106 additions & 0 deletions stubs/pyluach/pyluach/dates.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import abc
import datetime
from collections.abc import Generator
from enum import Enum
from typing import TypedDict, overload, type_check_only
from typing_extensions import Self

@type_check_only
class _DateDict(TypedDict):
year: int
month: int
day: int

class Rounding(Enum):
PREVIOUS_DAY = 1
NEXT_DAY = 2
EXCEPTION = 3

class BaseDate(abc.ABC, metaclass=abc.ABCMeta):
@property
@abc.abstractmethod
def jd(self) -> float: ...
@abc.abstractmethod
def to_heb(self) -> HebrewDate: ...
def __hash__(self) -> int: ...
def __add__(self, other: float) -> BaseDate: ...
@overload
def __sub__(self, other: float) -> BaseDate: ...
@overload
def __sub__(self, other: BaseDate) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __lt__(self, other: object) -> bool: ...
def __gt__(self, other: object) -> bool: ...
def __le__(self, other: object) -> bool: ...
def __ge__(self, other: object) -> bool: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
def shabbos(self) -> Self: ...
def fast_day(self, hebrew: bool = False) -> str | None: ...
def festival(
self, israel: bool = False, hebrew: bool = False, include_working_days: bool = True, prefix_day: bool = False
) -> str | None: ...
def holiday(self, israel: bool = False, hebrew: bool = False, prefix_day: bool = False) -> str | None: ...

class CalendarDateMixin:
year: int
month: int
day: int
def __init__(self, year: int, month: int, day: int, jd: float | None = None) -> None: ...
def __iter__(self) -> Generator[int]: ...
def tuple(self) -> tuple[int, int, int]: ...
def dict(self) -> _DateDict: ...
def replace(self, year: int | None = None, month: int | None = None, day: int | None = None) -> Self: ...

class JulianDay(BaseDate):
day: float
def __init__(self, day: float) -> None: ...
@property
def jd(self) -> float: ...
@staticmethod
def from_pydate(pydate: datetime.date) -> JulianDay: ...
@staticmethod
def today() -> JulianDay: ...
def to_greg(self) -> GregorianDate: ...
def to_heb(self) -> HebrewDate: ...
def to_pydate(self) -> datetime.date: ...

class GregorianDate(BaseDate, CalendarDateMixin):
def __init__(self, year: int, month: int, day: int, jd: float | None = None) -> None: ...
def __format__(self, fmt: str) -> str: ...
def strftime(self, fmt: str) -> str: ...
@property
def jd(self) -> float: ...
@classmethod
def from_pydate(cls, pydate: datetime.date) -> Self: ...
@staticmethod
def today() -> GregorianDate: ...
def is_leap(self) -> bool: ...
def to_jd(self) -> JulianDay: ...
def to_heb(self) -> HebrewDate: ...
def to_pydate(self) -> datetime.date: ...

class HebrewDate(BaseDate, CalendarDateMixin):
def __init__(self, year: int, month: int, day: int, jd: float | None = None) -> None: ...
def __format__(self, fmt: str) -> str: ...
@property
def jd(self) -> float: ...
@staticmethod
def from_pydate(pydate: datetime.date) -> HebrewDate: ...
@staticmethod
def today() -> HebrewDate: ...
def to_jd(self) -> JulianDay: ...
def to_greg(self) -> GregorianDate: ...
def to_pydate(self) -> datetime.date: ...
def to_heb(self) -> HebrewDate: ...
def month_name(self, hebrew: bool = False) -> str: ...
def hebrew_day(self, withgershayim: bool = True) -> str: ...
def hebrew_year(self, thousands: bool = False, withgershayim: bool = True) -> str: ...
def hebrew_date_string(self, thousands: bool = False) -> str: ...
def add(
self, years: int = 0, months: int = 0, days: int = 0, adar1: bool | None = False, rounding: Rounding = Rounding.NEXT_DAY
) -> HebrewDate: ...
def subtract(
self, years: int = 0, months: int = 0, days: int = 0, adar1: bool | None = False, rounding: Rounding = Rounding.NEXT_DAY
) -> HebrewDate: ...
141 changes: 141 additions & 0 deletions stubs/pyluach/pyluach/hebrewcal.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import calendar
import datetime
from collections.abc import Generator
from typing import Literal, TypedDict, overload, type_check_only
from typing_extensions import Self

from .dates import BaseDate, HebrewDate

@type_check_only
class _MoladDict(TypedDict):
weekday: int
hours: int
parts: int

@type_check_only
class _MoladAnnouncementDict(TypedDict):
weekday: int
hour: int
minutes: int
parts: int

class IllegalMonthError(ValueError):
month: int
def __init__(self, month: int) -> None: ...

class IllegalWeekdayError(ValueError):
weekday: int
def __init__(self, weekday: int) -> None: ...

class Year:
year: int
leap: bool
def __init__(self, year: int) -> None: ...
def __len__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __add__(self, other: int) -> Year: ...
@overload
def __sub__(self, other: int) -> Year: ...
@overload
def __sub__(self, other: Year) -> int: ...
def __gt__(self, other: Year) -> bool: ...
def __ge__(self, other: Year) -> bool: ...
def __lt__(self, other: Year) -> bool: ...
def __le__(self, other: Year) -> bool: ...
def __iter__(self) -> Generator[int]: ...
def monthscount(self) -> Literal[12, 13]: ...
def itermonths(self) -> Generator[Month]: ...
def iterdays(self) -> Generator[int]: ...
def iterdates(self) -> Generator[HebrewDate]: ...
@classmethod
def from_date(cls, date: BaseDate) -> Self: ...
@classmethod
def from_pydate(cls, pydate: datetime.date) -> Self: ...
def year_string(self, thousands: bool = False) -> str: ...

class Month:
year: int
month: int
def __init__(self, year: int, month: int) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Generator[int]: ...
def __eq__(self, other: object) -> bool: ...
def __add__(self, other: int) -> Month: ...
@overload
def __sub__(self, other: int) -> Month: ...
@overload
def __sub__(self, other: Month) -> int: ...
def __gt__(self, other: Month) -> bool: ...
def __ge__(self, other: Month) -> bool: ...
def __lt__(self, other: Month) -> bool: ...
def __le__(self, other: Month) -> bool: ...
@classmethod
def from_date(cls, date: BaseDate) -> Month: ...
@classmethod
def from_pydate(cls, pydate: datetime.date) -> Month: ...
def month_name(self, hebrew: bool = False) -> str: ...
def month_string(self, thousands: bool = False) -> str: ...
def starting_weekday(self) -> int: ...
def iterdates(self) -> Generator[HebrewDate]: ...
def molad(self) -> _MoladDict: ...
def molad_announcement(self) -> _MoladAnnouncementDict: ...

def to_hebrew_numeral(num: int, thousands: bool = False, withgershayim: bool = True) -> str: ...

class HebrewCalendar(calendar.Calendar):
hebrewnumerals: bool
hebrewweekdays: bool
hebrewmonths: bool
hebrewyear: bool
def __init__(
self,
firstweekday: int = 1,
hebrewnumerals: bool = True,
hebrewweekdays: bool = False,
hebrewmonths: bool = False,
hebrewyear: bool = False,
) -> None: ...
@property
def firstweekday(self) -> int: ...
@firstweekday.setter
def firstweekday(self, thefirstweekday: int) -> None: ...
def iterweekdays(self) -> Generator[int]: ...
def itermonthdates(self, year: int, month: int) -> Generator[HebrewDate]: ... # type: ignore[override]
def itermonthdays(self, year: int, month: int) -> Generator[int]: ...
def itermonthdays2(self, year: int, month: int) -> Generator[tuple[int, int]]: ...
def itermonthdays3(self, year: int, month: int) -> Generator[tuple[int, int, int]]: ...
def itermonthdays4(self, year: int, month: int) -> Generator[tuple[int, int, int, int]]: ...
def yeardatescalendar(self, year: int, width: int = 3) -> list[list[list[list[HebrewDate]]]]: ... # type: ignore[override]
def yeardays2calendar(self, year: int, width: int = 3) -> list[list[list[list[tuple[int, int]]]]]: ...
def yeardayscalendar(self, year: int, width: int = 3) -> list[list[list[list[int]]]]: ...
def monthdatescalendar(self, year: int, month: int) -> list[list[HebrewDate]]: ... # type: ignore[override]

class HebrewHTMLCalendar(HebrewCalendar, calendar.HTMLCalendar):
rtl: bool
def __init__(
self,
firstweekday: int = 1,
hebrewnumerals: bool = True,
hebrewweekdays: bool = False,
hebrewmonths: bool = False,
hebrewyear: bool = False,
rtl: bool = False,
) -> None: ...
def formatday(self, day: int, weekday: int) -> str: ...
def formatweekday(self, day: int) -> str: ...
def formatyearnumber(self, theyear: int) -> int | str: ...
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
def formatmonth(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
def formatyear(self, theyear: int, width: int = 3) -> str: ...

class HebrewTextCalendar(HebrewCalendar, calendar.TextCalendar):
def formatday(self, day: int, weekday: int, width: int) -> str: ...
def formatweekday(self, day: int, width: int) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, width: int = 0, withyear: bool = True) -> str: ...
def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...

def fast_day(date: BaseDate, hebrew: bool = False) -> str | None: ...
def festival(
date: BaseDate, israel: bool = False, hebrew: bool = False, include_working_days: bool = True, prefix_day: bool = False
) -> str | None: ...
def holiday(date: BaseDate, israel: bool = False, hebrew: bool = False, prefix_day: bool = False) -> str | None: ...
13 changes: 13 additions & 0 deletions stubs/pyluach/pyluach/parshios.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from collections import OrderedDict
from collections.abc import Generator
from typing import Final

from .dates import BaseDate, HebrewDate

PARSHIOS: Final[list[str]]
PARSHIOS_HEBREW: Final[list[str]]

def getparsha(date: BaseDate, israel: bool = False) -> list[int] | None: ...
def getparsha_string(date: BaseDate, israel: bool = False, hebrew: bool = False) -> str | None: ...
def iterparshios(year: int, israel: bool = False) -> Generator[list[int] | None]: ...
def parshatable(year: int, israel: bool = False) -> OrderedDict[HebrewDate, list[int] | None]: ...
32 changes: 32 additions & 0 deletions stubs/pyluach/pyluach/utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from enum import Enum
from typing import Final

class _Days(Enum):
ROSH_HASHANA = "Rosh Hashana"
YOM_KIPPUR = "Yom Kippur"
SUCCOS = "Succos"
SHMINI_ATZERES = "Shmini Atzeres"
SIMCHAS_TORAH = "Simchas Torah"
CHANUKA = "Chanuka"
TU_BSHVAT = "Tu B'shvat"
PURIM_KATAN = "Purim Katan"
PURIM = "Purim"
SHUSHAN_PURIM = "Shushan Purim"
PESACH = "Pesach"
PESACH_SHENI = "Pesach Sheni"
LAG_BAOMER = "Lag Ba'omer"
SHAVUOS = "Shavuos"
TU_BAV = "Tu B'av"
TZOM_GEDALIA = "Tzom Gedalia"
TENTH_OF_TEVES = "10 of Teves"
TAANIS_ESTHER = "Taanis Esther"
SEVENTEENTH_OF_TAMUZ = "17 of Tamuz"
NINTH_OF_AV = "9 of Av"

MONTH_NAMES: Final[list[str]]
MONTH_NAMES_HEBREW: Final[list[str]]
FAST_DAYS: Final[list[str]]
FAST_DAYS_HEBREW: Final[list[str]]
FESTIVALS: Final[list[str]]
FESTIVALS_HEBREW: Final[list[str]]
WEEKDAYS: Final[dict[int, str]]
Loading