-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Before:
from uplink import Consumer, get, Path, Query
class GitHub(Consumer):
"""A Python Client for the GitHub API."""
@get("users/{user}/repos")
def get_repos(self, user: Path, sort_by: Query("sort")):
"""Get user's public repositories."""After:
from typing import Annotated
from uplink import Consumer, get, Path, Query
class GitHub(Consumer):
"""A Python Client for the GitHub API."""
@get("users/{user}/repos")
def get_repos(self, user: Annotated[str, Path], sort_by: Annotated[str, Query("sort")]):
"""Get user's public repositories."""This is similar to how Pydantic deals with fields:
https://docs.pydantic.dev/latest/concepts/fields/#the-annotated-pattern
from typing import Annotated
from pydantic import BaseModel, Field, WithJsonSchema
class Model(BaseModel):
name: Annotated[str, Field(strict=True), WithJsonSchema({'extra': 'data'})]I don't mean for the current method to be completely replaced by this, only for this new method to also be supported.
glebignatieff, OlegDokuchaev, bobend, cd-fge and PhiFever
Metadata
Metadata
Assignees
Labels
No labels