8000 Merge pull request #90 from lbolla/issue88-calendar · python/typeshed@2e7163f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e7163f

Browse files
committed
Merge pull request #90 from lbolla/issue88-calendar
Issue 88: Stub for calendar module
2 parents a69eb27 + fb4910e commit 2e7163f

File tree

2 files changed

+147
-12
lines changed

2 files changed

+147
-12
lines changed

stdlib/2.7/calendar.pyi

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from typing import Any, Iterable, Optional, Tuple
2+
import datetime
3+
4+
LocaleType = Tuple[Optional[str], Optional[str]]
5+
6+
class IllegalMonthError(ValueError):
7+
def __init__(self, month: int) -> None: ...
8+
def __str__(self) -> str: ...
9+
10+
class IllegalWeekdayError(ValueError):
11+
def __init__(self, weekday: int) -> None: ...
12+
def __str__(self) -> str: ...
13+
14+
def isleap(year: int) -> bool: ...
15+
def leapdays(y1: int, y2: int) -> int: ...
16+
def weekday(year: int, month: int, day: int) -> int: ...
17+
def monthrange(year: int, month: int) -> Tuple[int, int]: ...
18+
19+
class Calendar(object):
20+
def __init__(self, firstweekday: int = 0) -> None: ...
21+
def getfirstweekday(self) -> int: ...
22+
def setfirstweekday(self, firstweekday: int) -> None: ...
23+
def iterweekdays(self) -> Iterable[int]: ...
24+
def itermonthdates(se 10000 lf, year: int, month: int) -> Iterable[datetime.date]: ...
25+
def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ...
26+
def itermonthdays(self, year: int, month: int) -> Iterable[int]: ...
27+
def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ...
28+
def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ...
29+
def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ...
30+
def yeardatescalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
31+
def yeardays2calendar(self, year: int, width: int = 3) -> List[List[Tuple[int, int]]]: ...
32+
def yeardayscalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
33+
34+
class TextCalendar(Calendar):
35+
def prweek(self, theweek: int, width: int) -> None: ...
36+
def formatday(self, day: int, weekday: int, width: int) -> str: ...
37+
def formatweek(self, theweek: int, width: int) -> str: ...
38+
def formatweekday(self, day: int, width: int) -> str: ...
39+
def formatweekheader(self, width: int) -> str: ...
40+
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
41+
def prmonth(self, theyear: int, themonth: int, w: Any=0, l: Any = 0) -> None: ...
42+
def formatmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ...
43+
def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...
44+
def pryear(self, theyear: int, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ...
45+
46+
class HTMLCalendar(Calendar):
47+
def formatday(self, day: int, weekday: int) -> str: ...
48+
def formatweek(self, theweek: int) -> str: ...
49+
def formatweekday(self, day: int) -> str: ...
50+
def formatweekheader(self) -> str: ...
51+
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
52+
def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
53+
def formatyear(self, theyear: int, width: int = 3) -> str: ...
54+
def formatyearpage(self, theyear: int, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ...
55+
56+
class TimeEncoding:
57+
def __init__(self, locale: LocaleType) -> None: ...
58+
def __enter__(self) -> LocaleType: ...
59+
def __exit__(self, *args) -> None: ...
60+
61+
class LocaleTextCalendar(TextCalendar):
62+
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
63+
def formatweekday(self, day: int, width: int) -> str: ...
64+
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
65+
66+
class LocaleHTMLCalendar(HTMLCalendar):
67+
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
68+
def formatweekday(self, day: int) -> str: ...
69+
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
70+
71+
c = ... # type: TextCalendar
72+
def setfirstweekday(firstweekday: int) -> None: ...
73+
def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
74+
def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
75+
def timegm(tuple: Tuple[int]) -> int: ...

stdlib/3/calendar.pyi

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,75 @@
1-
# Stubs for calendar
1+
from typing import Any, Iterable, Optional, Tuple
2+
import datetime
23

3-
# NOTE: These are incomplete!
4+
LocaleType = Tuple[Optional[str], Optional[str]]
45

5-
from typing import overload, Tuple
6+
class IllegalMonthError(ValueError):
7+
def __init__(self, month: int) -> None: ...
8+
def __str__(self) -> str: ...
69

7-
# TODO actually, any number of items larger than 5 is fine
8-
@overload
9-
def timegm(t: Tuple[int, int, int, int, int, int]) -> int: ...
10-
@overload
11-
def timegm(t: Tuple[int, int, int, int, int, int, int]) -> int: ...
12-
@overload
13-
def timegm(t: Tuple[int, int, int, int, int, int, int, int]) -> int: ...
14-
@overload
15-
def timegm(t: Tuple[int, int, int, int, int, int, int, int, int]) -> int: ...
10+
class IllegalWeekdayError(ValueError):
11+
def __init__(self, weekday: int) -> None: ...
12+
def __str__(self) -> str: ...
13+
14+
def isleap(year: int) -> bool: ...
15+
def leapdays(y1: int, y2: int) -> int: ...
16+
def weekday(year: int, month: int, day: int) -> int: ...
17+
def monthrange(year: int, month: int) -> Tuple[int, int]: ...
18+
19+
class Calendar(object):
20+
def __init__(self, firstweekday: int = 0) -> None: ...
21+
def getfirstweekday(self) -> int: ...
22+
def setfirstweekday(self, firstweekday: int) -> None: ...
23+
def iterweekdays(self) -> Iterable[int]: ...
24+
def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ...
25+
def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ...
26+
def itermonthdays(self, year: int, month: int) -> Iterable[int]: ...
27+
def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ...
28+
def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ...
29+
def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ...
30+
def yeardatescalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
31+
def yeardays2calendar(self, year: int, width: int = 3) -> List[List[Tuple[int, int]]]: ...
32+
def yeardayscalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
33+
34+
class TextCalendar(Calendar):
35+
def prweek(self, theweek: int, width: int) -> None: ...
36+
def formatday(self, day: int, weekday: int, width: int) -> str: ...
37+
def formatweek(self, theweek: int, width: int) -> str: ...
38+
def formatweekday(self, day: int, width: int) -> str: ...
39+
def formatweekheader(self, width: int) -> str: ...
40+
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
41+
def prmonth(self, theyear: int, themonth: int, w: Any=0, l: Any = 0) -> None: ...
42+
def formatmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ...
43+
def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...
44+
def pryear(self, theyear: int, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ...
45+
46+
class HTMLCalendar(Calendar):
47+
def formatday(self, day: int, weekday: int) -> str: ...
48+
def formatweek(self, theweek: int) -> str: ...
49+
def formatweekday(self, day: int) -> str: ...
50+
def formatweekheader(self) -> str: ...
51+
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
52+
def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
53+
def formatyear(self, theyear: int, width: int = 3) -> str: ...
54+
def formatyearpage(self, theyear: int, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ...
55+
56+
class different_locale:
57+
def __init__(self, locale: LocaleType) -> None: ...
58+
def __enter__(self) -> LocaleType: ...
59+
def __exit__(self, *args) -> None: ...
60+
61+
class LocaleTextCalendar(TextCalendar):
62+
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
63+
def formatweekday(self, day: int, width: int) -> str: ...
64+
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
65+
66+
class LocaleHTMLCalendar(HTMLCalendar):
67+
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
68+
def formatweekday(self, day: int) -> str: ...
69+
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
70+
71+
c = ... # type: TextCalendar
72+
def setfirstweekday(firstweekday: int) -> None: ...
73+
def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
74+
def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
75+
def timegm(tuple: Tuple[int]) -> int: ...

0 commit comments

Comments
 (0)
0