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
class User:
first_name: Annotated[str, Doc("The user's first name")]
last_name: Annotated[str, Doc("The user's last name")]
name: Annotated[str, Doc("The user's name")]
age: Annotated[int, Doc("The user's age")]
...
@ -264,8 +264,8 @@ Class attributes may be documented:
from typing import Annotated, Doc
class User:
first_name: Annotated[str, Doc("The user's first name")]
last_name: Annotated[str, Doc("The user's last name")]
name: Annotated[str, Doc("The user's 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
def create_user(
first_name: Annotated[str, Doc("The user's first name")],
last_name: Annotated[str, Doc("The user's last name")],
name: Annotated[str, Doc("The user's name")],
age: Annotated[int, Doc("The user's age")],
cursor: DatabaseConnection | None = None,
) -> Annotated[User, Doc("The created user after saving in the database")]:
"""Create a new user in the system.
@ -305,8 +305,8 @@ For example:
from typing_extensions import Doc
class User:
first_name: Annotated[str, Doc("The user's first name")]
last_name: Annotated[str, Doc("The user's last name")]
name: Annotated[str, Doc("The user's 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
class User:
first_name: str
"The user's first name"
last_name: str
"The user's last name"
name: str
"The user's name"
age: int
"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
class User:
first_name: Annotated[str, "The user's first name"]
last_name: Annotated[str, "The user's last name"]
name: Annotated[str, "The user's name"]
age: Annotated[int, "The user's age"]
...
@ -614,8 +614,8 @@ documentation string:
from typing import Doc
class User:
first_name: Doc[str, "The user's first name"]
last_name: Doc[str, "The user's last name"]
name: Doc[str, "The user's name"]
age: Doc[int, "The user's age"]
...