Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef74bee

Browse files
authored
Protocol naming guidelines (#4229)
Closes: #4174
1 parent 89d3a55 commit ef74bee

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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)