From d872968e326d4cdc1dd966266a0e00f5781a08ce Mon Sep 17 00:00:00 2001 From: Lorenzo Bolla Date: Wed, 24 Feb 2016 12:43:27 +0000 Subject: [PATCH 1/4] Issue 88: Stub for calendar module --- stdlib/2.7/calendar.pyi | 87 +++++++++++++++++++++++++++++++++++++ stdlib/3/calendar.pyi | 96 +++++++++++++++++++++++++++++++++++------ 2 files changed, 171 insertions(+), 12 deletions(-) create mode 100644 stdlib/2.7/calendar.pyi diff --git a/stdlib/2.7/calendar.pyi b/stdlib/2.7/calendar.pyi new file mode 100644 index 000000000..bfe0e0cbe --- /dev/null +++ b/stdlib/2.7/calendar.pyi @@ -0,0 +1,87 @@ +from typing import Any, Iterable, Optional, Tuple +import datetime + +YearType = int +MonthType = int +DayType = int +WeekdayType = int + +LocaleType = Tuple[Optional[str], Optional[str]] + +_colwidth = ... # type: int +_spacing = ... # type: int + +# TODO mypy complains about missing True/False +True = ... # type: bool +False = ... # type: bool + +class IllegalMonthError(ValueError): + def __init__(self, month: MonthType) -> None: ... + def __str__(self) -> str: ... + +class IllegalWeekdayError(ValueError): + def __init__(self, weekday: WeekdayType) -> None: ... + def __str__(self) -> str: ... + +def isleap(year: YearType) -> bool: ... +def leapdays(y1: YearType, y2: YearType) -> int: ... +def weekday(year: YearType, month: MonthType, day: DayType) -> WeekdayType: ... +def monthrange(year: YearType, month: MonthType) -> Tuple[WeekdayType, int]: ... + +class Calendar(object): + def __init__(self, firstweekday: WeekdayType=0) -> None: ... + def getfirstweekday(self) -> WeekdayType: ... + def setfirstweekday(self, firstweekday: WeekdayType) -> None: ... + def iterweekdays(self) -> Iterable[WeekdayType]: ... + def itermonthdates(self, year: YearType, month: MonthType) -> Iterable[datetime.date]: ... + def itermonthdays2(self, year: YearType, month: MonthType) -> Iterable[Tuple[DayType, WeekdayType]]: ... + def itermonthdays(self, year: YearType, month: MonthType) -> Iterable[DayType]: ... + def monthdatescalendar(self, year: YearType, month: MonthType) -> List[List[datetime.date]]: ... + def monthdays2calendar(self, year: YearType, month: MonthType) -> List[List[Tuple[DayType, WeekdayType]]]: ... + def monthdayscalendar(self, year: YearType, month: MonthType) -> List[List[DayType]]: ... + def yeardatescalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... + def yeardays2calendar(self, year: YearType, width: int=3) -> List[List[Tuple[DayType, WeekdayType]]]: ... + def yeardayscalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... + +class TextCalendar(Calendar): + def prweek(self, theweek: int, width: int) -> None: ... + def formatday(self, day: DayType, weekday: WeekdayType, width: int) -> str: ... + def formatweek(self, theweek: int, width: int) -> str: ... + def formatweekday(self, day: DayType, width: int) -> str: ... + def formatweekheader(self, width: int) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... + def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any=0) -> None: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, w: int=0, l: int=0) -> str: ... + def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int=6, m: int=3) -> str: ... + def pryear(self, theyear: YearType, w: Any=0, l: Any=0, c: Any=6, m: Any=3) -> None: ... + +class HTMLCalendar(Calendar): + def formatday(self, day: DayType, weekday: WeekdayType) -> str: ... + def formatweek(self, theweek: int) -> str: ... + def formatweekday(self, day: DayType) -> str: ... + def formatweekheader(self) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + def formatyear(self, theyear: YearType, width: int=3) -> str: ... + def formatyearpage(self, theyear: YearType, width: int=3, css: Optional[str]='calendar.css', encoding: Optional[str]=None) -> str: ... + +class TimeEncoding: + def __init__(self, locale: LocaleType) -> None: ... + def __enter__(self) -> LocaleType: ... + def __exit__(self, *args) -> None: ... + +class LocaleTextCalendar(TextCalendar): + def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def formatweekday(self, day: DayType, width: int) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... + +class LocaleHTMLCalendar(HTMLCalendar): + def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def formatweekday(self, day: DayType) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + +c = ... # type: TextCalendar +def setfirstweekday(firstweekday: WeekdayType) -> None: ... +def format(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... +def formatstring(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... +def timegm(tuple: Tuple[int]) -> int: ... diff --git a/stdlib/3/calendar.pyi b/stdlib/3/calendar.pyi index c0bfc733f..06df4b760 100644 --- a/stdlib/3/calendar.pyi +++ b/stdlib/3/calendar.pyi @@ -1,15 +1,87 @@ -# Stubs for calendar +from typing import Any, Iterable, Optional, Tuple +import datetime -# NOTE: These are incomplete! +YearType = int +MonthType = int +DayType = int +WeekdayType = int -from typing import overload, Tuple +LocaleType = Tuple[Optional[str], Optional[str]] -# TODO actually, any number of items larger than 5 is fine -@overload -def timegm(t: Tuple[int, int, int, int, int, int]) -> int: ... -@overload -def timegm(t: Tuple[int, int, int, int, int, int, int]) -> int: ... -@overload -def timegm(t: Tuple[int, int, int, int, int, int, int, int]) -> int: ... -@overload -def timegm(t: Tuple[int, int, int, int, int, int, int, int, int]) -> int: ... +_colwidth = ... # type: int +_spacing = ... # type: int + +# TODO mypy complains about missing True/False +True = ... # type: bool +False = ... # type: bool + +class IllegalMonthError(ValueError): + def __init__(self, month: MonthType) -> None: ... + def __str__(self) -> str: ... + +class IllegalWeekdayError(ValueError): + def __init__(self, weekday: WeekdayType) -> None: ... + def __str__(self) -> str: ... + +def isleap(year: YearType) -> bool: ... +def leapdays(y1: YearType, y2: YearType) -> int: ... +def weekday(year: YearType, month: MonthType, day: DayType) -> WeekdayType: ... +def monthrange(year: YearType, month: MonthType) -> Tuple[WeekdayType, int]: ... + +class Calendar(object): + def __init__(self, firstweekday: WeekdayType=0) -> None: ... + def getfirstweekday(self) -> WeekdayType: ... + def setfirstweekday(self, firstweekday: WeekdayType) -> None: ... + def iterweekdays(self) -> Iterable[WeekdayType]: ... + def itermonthdates(self, year: YearType, month: MonthType) -> Iterable[datetime.date]: ... + def itermonthdays2(self, year: YearType, month: MonthType) -> Iterable[Tuple[DayType, WeekdayType]]: ... + def itermonthdays(self, year: YearType, month: MonthType) -> Iterable[DayType]: ... + def monthdatescalendar(self, year: YearType, month: MonthType) -> List[List[datetime.date]]: ... + def monthdays2calendar(self, year: YearType, month: MonthType) -> List[List[Tuple[DayType, WeekdayType]]]: ... + def monthdayscalendar(self, year: YearType, month: MonthType) -> List[List[DayType]]: ... + def yeardatescalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... + def yeardays2calendar(self, year: YearType, width: int=3) -> List[List[Tuple[DayType, WeekdayType]]]: ... + def yeardayscalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... + +class TextCalendar(Calendar): + def prweek(self, theweek: int, width: int) -> None: ... + def formatday(self, day: DayType, weekday: WeekdayType, width: int) -> str: ... + def formatweek(self, theweek: int, width: int) -> str: ... + def formatweekday(self, day: DayType, width: int) -> str: ... + def formatweekheader(self, width: int) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... + def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any=0) -> None: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, w: int=0, l: int=0) -> str: ... + def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int=6, m: int=3) -> str: ... + def pryear(self, theyear: YearType, w: Any=0, l: Any=0, c: Any=6, m: Any=3) -> None: ... + +class HTMLCalendar(Calendar): + def formatday(self, day: DayType, weekday: WeekdayType) -> str: ... + def formatweek(self, theweek: int) -> str: ... + def formatweekday(self, day: DayType) -> str: ... + def formatweekheader(self) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + def formatyear(self, theyear: YearType, width: int=3) -> str: ... + def formatyearpage(self, theyear: YearType, width: int=3, css: Optional[str]='calendar.css', encoding: Optional[str]=None) -> str: ... + +class different_locale: + def __init__(self, locale: LocaleType) -> None: ... + def __enter__(self) -> LocaleType: ... + def __exit__(self, *args) -> None: ... + +class LocaleTextCalendar(TextCalendar): + def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def formatweekday(self, day: DayType, width: int) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... + +class LocaleHTMLCalendar(HTMLCalendar): + def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def formatweekday(self, day: DayType) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + +c = ... # type: TextCalendar +def setfirstweekday(firstweekday: WeekdayType) -> None: ... +def format(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... +def formatstring(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... +def timegm(tuple: Tuple[int]) -> int: ... From ce938b367b149cb936e2c4ff9fafffa6fbbacca5 Mon Sep 17 00:00:00 2001 From: Lorenzo Bolla Date: Wed, 24 Feb 2016 21:01:41 +0000 Subject: [PATCH 2/4] Remove True/False/None optional arguments. Use Optional[...] when appropriate. Adhere to PEP-484 styling. --- stdlib/2.7/calendar.pyi | 42 +++++++++++++++++++---------------------- stdlib/3/calendar.pyi | 42 +++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 46 deletions(-) diff --git a/stdlib/2.7/calendar.pyi b/stdlib/2.7/calendar.pyi index bfe0e0cbe..567e3a4af 100644 --- a/stdlib/2.7/calendar.pyi +++ b/stdlib/2.7/calendar.pyi @@ -11,10 +11,6 @@ LocaleType = Tuple[Optional[str], Optional[str]] _colwidth = ... # type: int _spacing = ... # type: int -# TODO mypy complains about missing True/False -True = ... # type: bool -False = ... # type: bool - class IllegalMonthError(ValueError): def __init__(self, month: MonthType) -> None: ... def __str__(self) -> str: ... @@ -29,7 +25,7 @@ def weekday(year: YearType, month: MonthType, day: DayType) -> WeekdayType: ... def monthrange(year: YearType, month: MonthType) -> Tuple[WeekdayType, int]: ... class Calendar(object): - def __init__(self, firstweekday: WeekdayType=0) -> None: ... + def __init__(self, firstweekday: WeekdayType = 0) -> None: ... def getfirstweekday(self) -> WeekdayType: ... def setfirstweekday(self, firstweekday: WeekdayType) -> None: ... def iterweekdays(self) -> Iterable[WeekdayType]: ... @@ -39,9 +35,9 @@ class Calendar(object): def monthdatescalendar(self, year: YearType, month: MonthType) -> List[List[datetime.date]]: ... def monthdays2calendar(self, year: YearType, month: MonthType) -> List[List[Tuple[DayType, WeekdayType]]]: ... def monthdayscalendar(self, year: YearType, month: MonthType) -> List[List[DayType]]: ... - def yeardatescalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... - def yeardays2calendar(self, year: YearType, width: int=3) -> List[List[Tuple[DayType, WeekdayType]]]: ... - def yeardayscalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... + def yeardatescalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... + def yeardays2calendar(self, year: YearType, width: int = 3) -> List[List[Tuple[DayType, WeekdayType]]]: ... + def yeardayscalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... @@ -49,21 +45,21 @@ class TextCalendar(Calendar): def formatweek(self, theweek: int, width: int) -> str: ... def formatweekday(self, day: DayType, width: int) -> str: ... def formatweekheader(self, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... - def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any=0) -> None: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, w: int=0, l: int=0) -> str: ... - def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int=6, m: int=3) -> str: ... - def pryear(self, theyear: YearType, w: Any=0, l: Any=0, c: Any=6, m: Any=3) -> None: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... + def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any = 0) -> None: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, w: int = 0, l: int = 0) -> str: ... + def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int = 6, m: int = 3) -> str: ... + def pryear(self, theyear: YearType, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... class HTMLCalendar(Calendar): def formatday(self, day: DayType, weekday: WeekdayType) -> str: ... def formatweek(self, theweek: int) -> str: ... def formatweekday(self, day: DayType) -> str: ... def formatweekheader(self) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... - def formatyear(self, theyear: YearType, width: int=3) -> str: ... - def formatyearpage(self, theyear: YearType, width: int=3, css: Optional[str]='calendar.css', encoding: Optional[str]=None) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... + def formatyear(self, theyear: YearType, width: int = 3) -> str: ... + def formatyearpage(self, theyear: YearType, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ... class TimeEncoding: def __init__(self, locale: LocaleType) -> None: ... @@ -71,17 +67,17 @@ class TimeEncoding: def __exit__(self, *args) -> None: ... class LocaleTextCalendar(TextCalendar): - def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... def formatweekday(self, day: DayType, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... class LocaleHTMLCalendar(HTMLCalendar): - def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... def formatweekday(self, day: DayType) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... c = ... # type: TextCalendar def setfirstweekday(firstweekday: WeekdayType) -> None: ... -def format(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... -def formatstring(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... +def format(cols: int, colwidth: int=_colwidth, spacing: int = _spacing) -> str: ... +def formatstring(cols: int, colwidth: int = _colwidth, spacing: int = _spacing) -> str: ... def timegm(tuple: Tuple[int]) -> int: ... diff --git a/stdlib/3/calendar.pyi b/stdlib/3/calendar.pyi index 06df4b760..b304ad143 100644 --- a/stdlib/3/calendar.pyi +++ b/stdlib/3/calendar.pyi @@ -11,10 +11,6 @@ LocaleType = Tuple[Optional[str], Optional[str]] _colwidth = ... # type: int _spacing = ... # type: int -# TODO mypy complains about missing True/False -True = ... # type: bool -False = ... # type: bool - class IllegalMonthError(ValueError): def __init__(self, month: MonthType) -> None: ... def __str__(self) -> str: ... @@ -29,7 +25,7 @@ def weekday(year: YearType, month: MonthType, day: DayType) -> WeekdayType: ... def monthrange(year: YearType, month: MonthType) -> Tuple[WeekdayType, int]: ... class Calendar(object): - def __init__(self, firstweekday: WeekdayType=0) -> None: ... + def __init__(self, firstweekday: WeekdayType = 0) -> None: ... def getfirstweekday(self) -> WeekdayType: ... def setfirstweekday(self, firstweekday: WeekdayType) -> None: ... def iterweekdays(self) -> Iterable[WeekdayType]: ... @@ -39,9 +35,9 @@ class Calendar(object): def monthdatescalendar(self, year: YearType, month: MonthType) -> List[List[datetime.date]]: ... def monthdays2calendar(self, year: YearType, month: MonthType) -> List[List[Tuple[DayType, WeekdayType]]]: ... def monthdayscalendar(self, year: YearType, month: MonthType) -> List[List[DayType]]: ... - def yeardatescalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... - def yeardays2calendar(self, year: YearType, width: int=3) -> List[List[Tuple[DayType, WeekdayType]]]: ... - def yeardayscalendar(self, year: YearType, width: int=3) -> List[List[DayType]]: ... + def yeardatescalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... + def yeardays2calendar(self, year: YearType, width: int = 3) -> List[List[Tuple[DayType, WeekdayType]]]: ... + def yeardayscalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... @@ -49,21 +45,21 @@ class TextCalendar(Calendar): def formatweek(self, theweek: int, width: int) -> str: ... def formatweekday(self, day: DayType, width: int) -> str: ... def formatweekheader(self, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... - def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any=0) -> None: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, w: int=0, l: int=0) -> str: ... - def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int=6, m: int=3) -> str: ... - def pryear(self, theyear: YearType, w: Any=0, l: Any=0, c: Any=6, m: Any=3) -> None: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... + def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any = 0) -> None: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, w: int = 0, l: int = 0) -> str: ... + def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int = 6, m: int = 3) -> str: ... + def pryear(self, theyear: YearType, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... class HTMLCalendar(Calendar): def formatday(self, day: DayType, weekday: WeekdayType) -> str: ... def formatweek(self, theweek: int) -> str: ... def formatweekday(self, day: DayType) -> str: ... def formatweekheader(self) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... - def formatyear(self, theyear: YearType, width: int=3) -> str: ... - def formatyearpage(self, theyear: YearType, width: int=3, css: Optional[str]='calendar.css', encoding: Optional[str]=None) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... + def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... + def formatyear(self, theyear: YearType, width: int = 3) -> str: ... + def formatyearpage(self, theyear: YearType, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ... class different_locale: def __init__(self, locale: LocaleType) -> None: ... @@ -71,17 +67,17 @@ class different_locale: def __exit__(self, *args) -> None: ... class LocaleTextCalendar(TextCalendar): - def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... def formatweekday(self, day: DayType, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool=True) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... class LocaleHTMLCalendar(HTMLCalendar): - def __init__(self, firstweekday: WeekdayType=0, locale: LocaleType=None) -> None: ... + def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... def formatweekday(self, day: DayType) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool=True) -> str: ... + def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... c = ... # type: TextCalendar def setfirstweekday(firstweekday: WeekdayType) -> None: ... -def format(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... -def formatstring(cols: int, colwidth: int=_colwidth, spacing: int=_spacing) -> str: ... +def format(cols: int, colwidth: int=_colwidth, spacing: int = _spacing) -> str: ... +def formatstring(cols: int, colwidth: int = _colwidth, spacing: int = _spacing) -> str: ... def timegm(tuple: Tuple[int]) -> int: ... From 12d348fe672b9e2a81155d362182d26dcc789f8e Mon Sep 17 00:00:00 2001 From: Lorenzo Bolla Date: Wed, 24 Feb 2016 22:19:25 +0000 Subject: [PATCH 3/4] Remove mention to internal variables --- stdlib/2.7/calendar.pyi | 10 +++------- stdlib/3/calendar.pyi | 9 +++------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/stdlib/2.7/calendar.pyi b/stdlib/2.7/calendar.pyi index 567e3a4af..59524b892 100644 --- a/stdlib/2.7/calendar.pyi +++ b/stdlib/2.7/calendar.pyi @@ -5,12 +5,8 @@ YearType = int MonthType = int DayType = int WeekdayType = int - LocaleType = Tuple[Optional[str], Optional[str]] -_colwidth = ... # type: int -_spacing = ... # type: int - class IllegalMonthError(ValueError): def __init__(self, month: MonthType) -> None: ... def __str__(self) -> str: ... @@ -48,7 +44,7 @@ class TextCalendar(Calendar): def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any = 0) -> None: ... def formatmonth(self, theyear: YearType, themonth: MonthType, w: int = 0, l: int = 0) -> str: ... - def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int = 6, m: int = 3) -> str: ... + def formatyear(self, theyear: YearType, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ... def pryear(self, theyear: YearType, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... class HTMLCalendar(Calendar): @@ -78,6 +74,6 @@ class LocaleHTMLCalendar(HTMLCalendar): c = ... # type: TextCalendar def setfirstweekday(firstweekday: WeekdayType) -> None: ... -def format(cols: int, colwidth: int=_colwidth, spacing: int = _spacing) -> str: ... -def formatstring(cols: int, colwidth: int = _colwidth, spacing: int = _spacing) -> str: ... +def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... +def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def timegm(tuple: Tuple[int]) -> int: ... diff --git a/stdlib/3/calendar.pyi b/stdlib/3/calendar.pyi index b304ad143..c8e4cefd8 100644 --- a/stdlib/3/calendar.pyi +++ b/stdlib/3/calendar.pyi @@ -8,9 +8,6 @@ WeekdayType = int LocaleType = Tuple[Optional[str], Optional[str]] -_colwidth = ... # type: int -_spacing = ... # type: int - class IllegalMonthError(ValueError): def __init__(self, month: MonthType) -> None: ... def __str__(self) -> str: ... @@ -48,7 +45,7 @@ class TextCalendar(Calendar): def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any = 0) -> None: ... def formatmonth(self, theyear: YearType, themonth: MonthType, w: int = 0, l: int = 0) -> str: ... - def formatyear(self, theyear: YearType, w: int=2, l: int=1, c: int = 6, m: int = 3) -> str: ... + def formatyear(self, theyear: YearType, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ... def pryear(self, theyear: YearType, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... class HTMLCalendar(Calendar): @@ -78,6 +75,6 @@ class LocaleHTMLCalendar(HTMLCalendar): c = ... # type: TextCalendar def setfirstweekday(firstweekday: WeekdayType) -> None: ... -def format(cols: int, colwidth: int=_colwidth, spacing: int = _spacing) -> str: ... -def formatstring(cols: int, colwidth: int = _colwidth, spacing: int = _spacing) -> str: ... +def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... +def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def timegm(tuple: Tuple[int]) -> int: ... From fb4910ed6ddeebe4933290ba2d157f3a12b78264 Mon Sep 17 00:00:00 2001 From: Lorenzo Bolla Date: Wed, 24 Feb 2016 22:38:32 +0000 Subject: [PATCH 4/4] Remove Year/Month/Day/Week type aliases --- stdlib/2.7/calendar.pyi | 82 +++++++++++++++++++--------------------- stdlib/3/calendar.pyi | 83 +++++++++++++++++++---------------------- 2 files changed, 78 insertions(+), 87 deletions(-) diff --git a/stdlib/2.7/calendar.pyi b/stdlib/2.7/calendar.pyi index 59524b892..d5d181387 100644 --- a/stdlib/2.7/calendar.pyi +++ b/stdlib/2.7/calendar.pyi @@ -1,61 +1,57 @@ from typing import Any, Iterable, Optional, Tuple import datetime -YearType = int -MonthType = int -DayType = int -WeekdayType = int LocaleType = Tuple[Optional[str], Optional[str]] class IllegalMonthError(ValueError): - def __init__(self, month: MonthType) -> None: ... + def __init__(self, month: int) -> None: ... def __str__(self) -> str: ... class IllegalWeekdayError(ValueError): - def __init__(self, weekday: WeekdayType) -> None: ... + def __init__(self, weekday: int) -> None: ... def __str__(self) -> str: ... -def isleap(year: YearType) -> bool: ... -def leapdays(y1: YearType, y2: YearType) -> int: ... -def weekday(year: YearType, month: MonthType, day: DayType) -> WeekdayType: ... -def monthrange(year: YearType, month: MonthType) -> Tuple[WeekdayType, int]: ... +def isleap(year: int) -> bool: ... +def leapdays(y1: int, y2: int) -> int: ... +def weekday(year: int, month: int, day: int) -> int: ... +def monthrange(year: int, month: int) -> Tuple[int, int]: ... class Calendar(object): - def __init__(self, firstweekday: WeekdayType = 0) -> None: ... - def getfirstweekday(self) -> WeekdayType: ... - def setfirstweekday(self, firstweekday: WeekdayType) -> None: ... - def iterweekdays(self) -> Iterable[WeekdayType]: ... - def itermonthdates(self, year: YearType, month: MonthType) -> Iterable[datetime.date]: ... - def itermonthdays2(self, year: YearType, month: MonthType) -> Iterable[Tuple[DayType, WeekdayType]]: ... - def itermonthdays(self, year: YearType, month: MonthType) -> Iterable[DayType]: ... - def monthdatescalendar(self, year: YearType, month: MonthType) -> List[List[datetime.date]]: ... - def monthdays2calendar(self, year: YearType, month: MonthType) -> List[List[Tuple[DayType, WeekdayType]]]: ... - def monthdayscalendar(self, year: YearType, month: MonthType) -> List[List[DayType]]: ... - def yeardatescalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... - def yeardays2calendar(self, year: YearType, width: int = 3) -> List[List[Tuple[DayType, WeekdayType]]]: ... - def yeardayscalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... + def __init__(self, firstweekday: int = 0) -> None: ... + def getfirstweekday(self) -> int: ... + def setfirstweekday(self, firstweekday: int) -> None: ... + def iterweekdays(self) -> Iterable[int]: ... + def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ... + def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ... + def itermonthdays(self, year: int, month: int) -> Iterable[int]: ... + def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ... + def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ... + def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ... + def yeardatescalendar(self, year: int, width: int = 3) -> List[List[int]]: ... + def yeardays2calendar(self, year: int, width: int = 3) -> List[List[Tuple[int, int]]]: ... + def yeardayscalendar(self, year: int, width: int = 3) -> List[List[int]]: ... class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... - def formatday(self, day: DayType, weekday: WeekdayType, width: int) -> str: ... + def formatday(self, day: int, weekday: int, width: int) -> str: ... def formatweek(self, theweek: int, width: int) -> str: ... - def formatweekday(self, day: DayType, width: int) -> str: ... + def formatweekday(self, day: int, width: int) -> str: ... def formatweekheader(self, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... - def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any = 0) -> None: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, w: int = 0, l: int = 0) -> str: ... - def formatyear(self, theyear: YearType, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ... - def pryear(self, theyear: YearType, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... + def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... + def prmonth(self, theyear: int, themonth: int, w: Any=0, l: Any = 0) -> None: ... + def formatmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ... + def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ... + def pryear(self, theyear: int, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... class HTMLCalendar(Calendar): - def formatday(self, day: DayType, weekday: WeekdayType) -> str: ... + def formatday(self, day: int, weekday: int) -> str: ... def formatweek(self, theweek: int) -> str: ... - def formatweekday(self, day: DayType) -> str: ... + def formatweekday(self, day: int) -> str: ... def formatweekheader(self) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... - def formatyear(self, theyear: YearType, width: int = 3) -> str: ... - def formatyearpage(self, theyear: YearType, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... + def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... + def formatyear(self, theyear: int, width: int = 3) -> str: ... + def formatyearpage(self, theyear: int, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ... class TimeEncoding: def __init__(self, locale: LocaleType) -> None: ... @@ -63,17 +59,17 @@ class TimeEncoding: def __exit__(self, *args) -> None: ... class LocaleTextCalendar(TextCalendar): - def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... - def formatweekday(self, day: DayType, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... + def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ... + def formatweekday(self, day: int, width: int) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... class LocaleHTMLCalendar(HTMLCalendar): - def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... - def formatweekday(self, day: DayType) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... + def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ... + def formatweekday(self, day: int) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... c = ... # type: TextCalendar -def setfirstweekday(firstweekday: WeekdayType) -> None: ... +def setfirstweekday(firstweekday: int) -> None: ... def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def timegm(tuple: Tuple[int]) -> int: ... diff --git a/stdlib/3/calendar.pyi b/stdlib/3/calendar.pyi index c8e4cefd8..b5de564f5 100644 --- a/stdlib/3/calendar.pyi +++ b/stdlib/3/calendar.pyi @@ -1,62 +1,57 @@ from typing import Any, Iterable, Optional, Tuple import datetime -YearType = int -MonthType = int -DayType = int -WeekdayType = int - LocaleType = Tuple[Optional[str], Optional[str]] class IllegalMonthError(ValueError): - def __init__(self, month: MonthType) -> None: ... + def __init__(self, month: int) -> None: ... def __str__(self) -> str: ... class IllegalWeekdayError(ValueError): - def __init__(self, weekday: WeekdayType) -> None: ... + def __init__(self, weekday: int) -> None: ... def __str__(self) -> str: ... -def isleap(year: YearType) -> bool: ... -def leapdays(y1: YearType, y2: YearType) -> int: ... -def weekday(year: YearType, month: MonthType, day: DayType) -> WeekdayType: ... -def monthrange(year: YearType, month: MonthType) -> Tuple[WeekdayType, int]: ... +def isleap(year: int) -> bool: ... +def leapdays(y1: int, y2: int) -> int: ... +def weekday(year: int, month: int, day: int) -> int: ... +def monthrange(year: int, month: int) -> Tuple[int, int]: ... class Calendar(object): - def __init__(self, firstweekday: WeekdayType = 0) -> None: ... - def getfirstweekday(self) -> WeekdayType: ... - def setfirstweekday(self, firstweekday: WeekdayType) -> None: ... - def iterweekdays(self) -> Iterable[WeekdayType]: ... - def itermonthdates(self, year: YearType, month: MonthType) -> Iterable[datetime.date]: ... - def itermonthdays2(self, year: YearType, month: MonthType) -> Iterable[Tuple[DayType, WeekdayType]]: ... - def itermonthdays(self, year: YearType, month: MonthType) -> Iterable[DayType]: ... - def monthdatescalendar(self, year: YearType, month: MonthType) -> List[List[datetime.date]]: ... - def monthdays2calendar(self, year: YearType, month: MonthType) -> List[List[Tuple[DayType, WeekdayType]]]: ... - def monthdayscalendar(self, year: YearType, month: MonthType) -> List[List[DayType]]: ... - def yeardatescalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... - def yeardays2calendar(self, year: YearType, width: int = 3) -> List[List[Tuple[DayType, WeekdayType]]]: ... - def yeardayscalendar(self, year: YearType, width: int = 3) -> List[List[DayType]]: ... + def __init__(self, firstweekday: int = 0) -> None: ... + def getfirstweekday(self) -> int: ... + def setfirstweekday(self, firstweekday: int) -> None: ... + def iterweekdays(self) -> Iterable[int]: ... + def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ... + def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ... + def itermonthdays(self, year: int, month: int) -> Iterable[int]: ... + def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ... + def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ... + def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ... + def yeardatescalendar(self, year: int, width: int = 3) -> List[List[int]]: ... + def yeardays2calendar(self, year: int, width: int = 3) -> List[List[Tuple[int, int]]]: ... + def yeardayscalendar(self, year: int, width: int = 3) -> List[List[int]]: ... class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... - def formatday(self, day: DayType, weekday: WeekdayType, width: int) -> str: ... + def formatday(self, day: int, weekday: int, width: int) -> str: ... def formatweek(self, theweek: int, width: int) -> str: ... - def formatweekday(self, day: DayType, width: int) -> str: ... + def formatweekday(self, day: int, width: int) -> str: ... def formatweekheader(self, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... - def prmonth(self, theyear: YearType, themonth: MonthType, w: Any=0, l: Any = 0) -> None: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, w: int = 0, l: int = 0) -> str: ... - def formatyear(self, theyear: YearType, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ... - def pryear(self, theyear: YearType, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... + def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... + def prmonth(self, theyear: int, themonth: int, w: Any=0, l: Any = 0) -> None: ... + def formatmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ... + def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ... + def pryear(self, theyear: int, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ... class HTMLCalendar(Calendar): - def formatday(self, day: DayType, weekday: WeekdayType) -> str: ... + def formatday(self, day: int, weekday: int) -> str: ... def formatweek(self, theweek: int) -> str: ... - def formatweekday(self, day: DayType) -> str: ... + def formatweekday(self, day: int) -> str: ... def formatweekheader(self) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... - def formatmonth(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... - def formatyear(self, theyear: YearType, width: int = 3) -> str: ... - def formatyearpage(self, theyear: YearType, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... + def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... + def formatyear(self, theyear: int, width: int = 3) -> str: ... + def formatyearpage(self, theyear: int, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ... class different_locale: def __init__(self, locale: LocaleType) -> None: ... @@ -64,17 +59,17 @@ class different_locale: def __exit__(self, *args) -> None: ... class LocaleTextCalendar(TextCalendar): - def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... - def formatweekday(self, day: DayType, width: int) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, width: int, withyear: bool = ...) -> str: ... + def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ... + def formatweekday(self, day: int, width: int) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... class LocaleHTMLCalendar(HTMLCalendar): - def __init__(self, firstweekday: WeekdayType = 0, locale: Optional[LocaleType] = ...) -> None: ... - def formatweekday(self, day: DayType) -> str: ... - def formatmonthname(self, theyear: YearType, themonth: MonthType, withyear: bool = ...) -> str: ... + def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ... + def formatweekday(self, day: int) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... c = ... # type: TextCalendar -def setfirstweekday(firstweekday: WeekdayType) -> None: ... +def setfirstweekday(firstweekday: int) -> None: ... def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def timegm(tuple: Tuple[int]) -> int: ...