Skip to content

Commit

Permalink
Start using Annotated types
Browse files Browse the repository at this point in the history
Tidier when Pydantic's Field info doesn't have to take the place of
the default value.
  • Loading branch information
andreaso committed Jan 6, 2025
1 parent eaf6313 commit 9ea9ca1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hv4gha/gh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
from datetime import datetime
from typing import Final, Literal, TypedDict
from typing import Annotated, Final, Literal, TypedDict

import requests
from pydantic import BaseModel, Field, TypeAdapter, ValidationError
Expand Down Expand Up @@ -49,9 +49,9 @@ class GitHubErrors(BaseModel):
class AccountInfo(BaseModel):
"""Part of Installation"""

login: str = Field(
max_length=39, pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?$"
)
login: Annotated[
str, Field(max_length=39, pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?$")
]


class Installation(BaseModel):
Expand Down Expand Up @@ -107,7 +107,7 @@ class TokenPermissions(BaseModel):
class Repository(BaseModel):
"""Part of AccessToken"""

name: str = Field(max_length=100, pattern=r"^[a-zA-Z0-9_\-\.]+$")
name: Annotated[str, Field(max_length=100, pattern=r"^[a-zA-Z0-9_\-\.]+$")]


class AccessToken(BaseModel):
Expand Down

0 comments on commit 9ea9ca1

Please sign in to comment.