PEP 727: Update `first_name` to `name` from feedback by Gregory P. Smith (#3478)

This commit is contained in:
Sebastián Ramírez 2023-10-12 16:16:44 +02:00 committed by GitHub
parent 6c817a6bb7
commit 7fba02d76c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 16 deletions

View File

@ -163,8 +163,8 @@ For example:
from typing import Annotated, Doc from typing import Annotated, Doc
class User: class User:
first_name: Annotated[str, Doc("The user's first name")] name: Annotated[str, Doc("The user's name")]
last_name: Annotated[str, Doc("The user's last name")] age: Annotated[int, Doc("The user's age")]
... ...
@ -264,8 +264,8 @@ Class attributes may be documented:
from typing import Annotated, Doc from typing import Annotated, Doc
class User: class User:
first_name: Annotated[str, Doc("The user's first name")] name: Annotated[str, Doc("The user's name")]
last_name: Annotated[str, Doc("The user's last name")] age: Annotated[int, Doc("The user's age")]
... ...
@ -276,8 +276,8 @@ As can function or method parameters and return values:
from typing import Annotated, Doc from typing import Annotated, Doc
def create_user( def create_user(
first_name: Annotated[str, Doc("The user's first name")], name: Annotated[str, Doc("The user's name")],
last_name: Annotated[str, Doc("The user's last name")], age: Annotated[int, Doc("The user's age")],
cursor: DatabaseConnection | None = None, cursor: DatabaseConnection | None = None,
) -> Annotated[User, Doc("The created user after saving in the database")]: ) -> Annotated[User, Doc("The created user after saving in the database")]:
"""Create a new user in the system. """Create a new user in the system.
@ -305,8 +305,8 @@ For example:
from typing_extensions import Doc from typing_extensions import Doc
class User: class User:
first_name: Annotated[str, Doc("The user's first name")] name: Annotated[str, Doc("The user's name")]
last_name: Annotated[str, Doc("The user's last name")] age: Annotated[int, Doc("The user's age")]
... ...
@ -563,10 +563,10 @@ of a symbol and providing runtime access to those values:
.. code:: python .. code:: python
class User: class User:
first_name: str name: str
"The user's first name" "The user's name"
last_name: str age: int
"The user's last name" "The user's age"
... ...
@ -588,8 +588,8 @@ In the discussion, it was also suggested to use a plain string inside of
from typing import Annotated from typing import Annotated
class User: class User:
first_name: Annotated[str, "The user's first name"] name: Annotated[str, "The user's name"]
last_name: Annotated[str, "The user's last name"] age: Annotated[int, "The user's age"]
... ...
@ -614,8 +614,8 @@ documentation string:
from typing import Doc from typing import Doc
class User: class User:
first_name: Doc[str, "The user's first name"] name: Doc[str, "The user's name"]
last_name: Doc[str, "The user's last name"] age: Doc[int, "The user's age"]
... ...