From 070614c432d47363c75391e13515baedc1a40348 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 2 Jan 2018 13:39:43 +0100 Subject: [PATCH 1/5] CONTRIBUTING: Use PEP 526 syntax in example --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f9fec6c5c1f..edbf7b77da00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,10 +145,10 @@ that you know. The below is an excerpt from the types for the `datetime` module. ```python -MAXYEAR = ... # type: int -MINYEAR = ... # type: int +MAXYEAR: int = ... +MINYEAR: int = ... -class date(object): +class date: def __init__(self, year: int, month: int, day: int) -> None: ... @classmethod def fromtimestamp(cls, timestamp: float) -> date: ... From 1fcb376e46fb16a5124918d1e1a75f5555810fa9 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 2 Jan 2018 13:45:36 +0100 Subject: [PATCH 2/5] CONTRIBUTING: Add an example property, whitespace for grouping --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index edbf7b77da00..31c6e6356940 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -150,12 +150,17 @@ MINYEAR: int = ... class date: def __init__(self, year: int, month: int, day: int) -> None: ... + @classmethod def fromtimestamp(cls, timestamp: float) -> date: ... @classmethod def today(cls) -> date: ... @classmethod def fromordinal(cls, ordinal: int) -> date: ... + + @property + def year(self) -> int: ... + def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ... def ctime(self) -> str: ... def weekday(self) -> int: ... From 4ab082f7b26c963345ab55914f667eb59af85b94 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 2 Jan 2018 15:19:00 +0100 Subject: [PATCH 3/5] CONTRIBUTING: No default values from module-level constants --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 31c6e6356940..094d769eb07d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,8 +145,8 @@ that you know. The below is an excerpt from the types for the `datetime` module. ```python -MAXYEAR: int = ... -MINYEAR: int = ... +MAXYEAR: int +MINYEAR: int class date: def __init__(self, year: int, month: int, day: int) -> None: ... From d7933e0a358051fe8a2da21ccc2702d6630eb217 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 2 Jan 2018 16:07:55 +0100 Subject: [PATCH 4/5] CONTRIBUTING: Remove spurious blank lines in example --- CONTRIBUTING.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 094d769eb07d..2b20213729fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -150,17 +150,14 @@ MINYEAR: int class date: def __init__(self, year: int, month: int, day: int) -> None: ... - @classmethod def fromtimestamp(cls, timestamp: float) -> date: ... @classmethod def today(cls) -> date: ... @classmethod def fromordinal(cls, ordinal: int) -> date: ... - @property def year(self) -> int: ... - def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ... def ctime(self) -> str: ... def weekday(self) -> int: ... From 0f3ed2e992cc0e82997ff95f4d06cc87f6e4af73 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 10 Jan 2018 00:13:20 +0100 Subject: [PATCH 5/5] Document that PEP 526 syntax is preferred --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2b20213729fc..38350dff8241 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -182,6 +182,8 @@ rule is that they should be as concise as possible. Specifically: * use a single blank line between top-level class definitions, or none if the classes are very small; * do not use docstrings; +* use variable annotations instead of type comments, even for stubs + that target older versions of Python; * for arguments with a type and a default, use spaces around the `=`. Stub files should only contain information necessary for the type