-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protocol naming convention #4174
Comments
Overall, I like this! Some off the cuff notes:
|
I decided to look at the existing one-shot protocols in
Most are of the I'd favor defaulting to |
Revised proposal:
|
I like the proposed plan. Apologies for the delay, life has been hectic. |
Now that we have a central stub for common types and protocols, we should think about how we name protocols in typeshed. Currently there is no common convention. Some possible conventions for a "read" protocol:
Readable
HasRead
SupportsRead
IsReadable
Reader
I have no strong preferences, but I think the naming to reflect that a class is a protocol. Therefore I'd suggest we should use either, some, or all of the above. The second name (
HasRead
) clearly implies the existence of a fieldread
, but would exclude protocols with multiple fields, such as this fromstdlib/3.9/zoneinfo/__init__.pyi
:Here is a proposal to start the discussion:
Iterator
,Container
).SupportsX
for protocols that provide type conversion (e.g.SupportsInt
).Xable
for protocols that provide callable methods (e.g.Readable
,LineReadable
,BytesReadable
,ReadSeekable
).HasX
for protocols that have readable and/or writable attributes or getter/setter methods (e.g.HasItems
,HasFileno
).The text was updated successfully, but these errors were encountered: