Skip to content

Commit 14defcb

Browse files
srittauVishal Kuo
authored and
Vishal Kuo
committed
Protocol naming guidelines (python#4229)
Closes: python#4174
1 parent 81169b3 commit 14defcb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,16 @@ are not sure whether exceptions are suppressed or not or if the
285285
context manager is meant to be subclassed, pick `Optional[bool]`.
286286
See https://github.com/python/mypy/issues/7214 for more details.
287287

288+
A few guidelines for protocol names below. In cases that don't fall
289+
into any of those categories, use your best judgement.
290+
291+
* Use plain names for protocols that represent a clear concept
292+
(e.g. `Iterator`, `Container`).
293+
* Use `SupportsX` for protocols that provide callable methods (e.g.
294+
`SupportsInt`, `SupportsRead`, `SupportsReadSeek`).
295+
* Use `HasX` for protocols that have readable and/or writable attributes
296+
or getter/setter methods (e.g. `HasItems`, `HasFileno`).
297+
288298
NOTE: there are stubs in this repository that don't conform to the
289299
style described above. Fixing them is a great starting point for new
290300
contributors.

0 commit comments

Comments
 (0)