Skip to content

Commit 35edccc

Browse files
srittauJelleZijlstra
authored andcommitted
CONTRIBUTING: Use PEP 526 syntax in example (#1803)
* Add an example property, whitespace for grouping * No default values from module-level constants * Document that PEP 526 syntax is preferred
1 parent f207bc3 commit 35edccc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,19 @@ that you know.
148148
The below is an excerpt from the types for the `datetime` module.
149149

150150
```python
151-
MAXYEAR = ... # type: int
152-
MINYEAR = ... # type: int
151+
MAXYEAR: int
152+
MINYEAR: int
153153

154-
class date(object):
154+
class date:
155155
def __init__(self, year: int, month: int, day: int) -> None: ...
156156
@classmethod
157157
def fromtimestamp(cls, timestamp: float) -> date: ...
158158
@classmethod
159159
def today(cls) -> date: ...
160160
@classmethod
161161
def fromordinal(cls, ordinal: int) -> date: ...
162+
@property
163+
def year(self) -> int: ...
162164
def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ...
163165
def ctime(self) -> str: ...
164166
def weekday(self) -> int: ...
@@ -183,6 +185,8 @@ rule is that they should be as concise as possible. Specifically:
183185
* use a single blank line between top-level class definitions, or none
184186
if the classes are very small;
185187
* do not use docstrings;
188+
* use variable annotations instead of type comments, even for stubs
189+
that target older versions of Python;
186190
* for arguments with a type and a default, use spaces around the `=`.
187191

188192
Stub files should only contain information necessary for the type

0 commit comments

Comments
 (0)