Skip to content

Commit

Permalink
fix: Run poetry run bump-pydantic ancv
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Aug 4, 2023
1 parent 7d0dd02 commit 36ca4a5
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 74 deletions.
16 changes: 8 additions & 8 deletions ancv/data/models/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class File(BaseModel):
See: https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#list-gists-for-the-authenticated-user, under the "files" key.
"""

filename: Optional[str]
type: Optional[str]
language: Optional[str]
raw_url: Optional[HttpUrl]
size: Optional[int]
filename: Optional[str] = None
type: Optional[str] = None
language: Optional[str] = None
raw_url: Optional[HttpUrl] = None
size: Optional[int] = None


class GistUser(BaseModel):
Expand All @@ -34,7 +34,7 @@ class GistUser(BaseModel):
..., examples=["https://github.com/images/error/octocat_happy.gif"]
)
gravatar_id: Optional[str] = Field(
..., examples=["41d064eb2195891e12d0413f63227ea7"]
None, examples=["41d064eb2195891e12d0413f63227ea7"]
)
url: HttpUrl = Field(..., examples=["https://api.github.com/users/octocat"])
html_url: HttpUrl = Field(..., examples=["https://github.com/octocat"])
Expand Down Expand Up @@ -87,9 +87,9 @@ class Gist(BaseModel):
public: bool
created_at: datetime
updated_at: datetime
description: Optional[str]
description: Optional[str] = None
comments: int
user: Optional[GistUser]
user: Optional[GistUser] = None
comments_url: HttpUrl
owner: Optional[GistUser] = None
truncated: Optional[bool] = None
76 changes: 22 additions & 54 deletions ancv/data/models/resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
from datetime import date, datetime
from typing import Optional, Union

from pydantic import AnyUrl, BaseModel, EmailStr, Extra, Field
from pydantic import ConfigDict, AnyUrl, BaseModel, EmailStr, Field


class Location(BaseModel):
"""Modelling a JSON resume location item.
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L50-L73
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

address: Optional[str] = Field(
None,
Expand All @@ -40,9 +38,7 @@ class Profile(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L74-L99
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

network: Optional[str] = Field(None, description="e.g. Facebook or Twitter")
username: Optional[str] = Field(None, description="e.g. neutralthoughts")
Expand All @@ -56,9 +52,7 @@ class Basics(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L17-L49
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = None
label: Optional[str] = Field(None, description="e.g. Web Developer")
Expand Down Expand Up @@ -89,9 +83,7 @@ class Certificate(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L264-L292
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = Field(
None, description="e.g. Certified Kubernetes Administrator"
Expand All @@ -106,9 +98,7 @@ class Skill(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L324-L351
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = Field(None, description="e.g. Web Development")
level: Optional[str] = Field(None, description="e.g. Master")
Expand All @@ -122,9 +112,7 @@ class Language(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L352-L370
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

language: Optional[str] = Field(None, description="e.g. English, Spanish")
fluency: Optional[str] = Field(None, description="e.g. Fluent, Beginner")
Expand All @@ -135,9 +123,7 @@ class Interest(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L371-L392
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = Field(None, description="e.g. Philosophy")
keywords: Optional[list[str]] = None
Expand All @@ -148,9 +134,7 @@ class Reference(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L393-L411
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = Field(None, description="e.g. Timothy Cook")
reference: Optional[str] = Field(
Expand All @@ -166,21 +150,19 @@ class TemplateConfig(BaseModel):
It occurs as an additional, but optional field in the JSON resume.
"""

template: Optional[str]
theme: Optional[str]
language: Optional[str]
ascii_only: Optional[bool]
dec31_as_year: Optional[bool]
template: Optional[str] = None
theme: Optional[str] = None
language: Optional[str] = None
ascii_only: Optional[bool] = None
dec31_as_year: Optional[bool] = None


class Meta(BaseModel):
"""Modelling a JSON resume meta item.
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L477-L497
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

canonical: Optional[AnyUrl] = Field(
None, description="URL (as per RFC 3986) to latest version of this document"
Expand All @@ -203,9 +185,7 @@ class WorkItem(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L100-L149
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = Field(None, description="e.g. Facebook")
location: Optional[str] = Field(None, description="e.g. Menlo Park, CA")
Expand All @@ -227,9 +207,7 @@ class VolunteerItem(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L150-L191
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

organization: Optional[str] = Field(None, description="e.g. Facebook")
position: Optional[str] = Field(None, description="e.g. Software Engineer")
Expand All @@ -249,9 +227,7 @@ class EducationItem(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L192-L237
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

institution: Optional[str] = Field(
None, description="e.g. Massachusetts Institute of Technology"
Expand All @@ -272,9 +248,7 @@ class Award(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L238-L263
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

title: Optional[str] = Field(
None, description="e.g. One of the 100 greatest minds of the century"
Expand All @@ -291,9 +265,7 @@ class Publication(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L293-L323
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = Field(None, description="e.g. The World Wide Web")
publisher: Optional[str] = Field(None, description="e.g. IEEE, Computer Magazine")
Expand All @@ -313,9 +285,7 @@ class Project(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json#L412-L476
"""

class Config:
extra = Extra.allow
model_config = ConfigDict(extra="allow")

name: Optional[str] = Field(None, description="e.g. The World Wide Web")
description: Optional[str] = Field(
Expand Down Expand Up @@ -351,9 +321,7 @@ class ResumeSchema(BaseModel):
See: https://github.com/alexpovel/resume-schema/blob/6e3244639cebfa89e66ee60d47c665a96e01a811/schema.json
"""

class Config:
extra = Extra.forbid
model_config = ConfigDict(extra="forbid")

schema_: Optional[AnyUrl] = Field(
None,
Expand Down
9 changes: 5 additions & 4 deletions ancv/reflection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from importlib.metadata import metadata
from typing import Optional

from pydantic import AnyUrl, BaseModel, EmailStr, Field, validator
from pydantic import field_validator, AnyUrl, BaseModel, EmailStr, Field

from ancv import PACKAGE

Expand All @@ -24,12 +24,12 @@ class Metadata(BaseModel):
)
name: str = Field(
description="Name of the package, e.g. 'ancv'",
regex=r"(?i)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",
pattern=r"(?i)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",
)
version: str = Field(
description="Version of the package, e.g. '0.1.0'",
# https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
regex=r"^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$",
pattern=r"^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$",
)
summary: Optional[str] = Field(
description="One-line summary of the package, e.g. 'Ancv is a package for ...'",
Expand Down Expand Up @@ -64,7 +64,8 @@ class Metadata(BaseModel):
description="Long description of the package, e.g. 'Ancv is a package for ...'",
)

@validator("project_url")
@field_validator("project_url")
@classmethod
def strip_prefix(cls, v: Optional[list[str]]) -> Optional[list[str]]:
"""Strips the prefixes 'Name, ' from the URLs.
Expand Down
10 changes: 3 additions & 7 deletions ancv/visualization/themes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from babel.dates import DateTimePattern, parse_pattern
from pydantic import BaseModel
from pydantic import ConfigDict, BaseModel
from rich.style import Style


Expand All @@ -13,9 +13,7 @@ class Emphasis(BaseModel):
strong: Style
medium: Style
weak: Style

class Config:
arbitrary_types_allowed = True # No validator for `Style` available
model_config = ConfigDict(arbitrary_types_allowed=True)


class DateFormat(BaseModel):
Expand All @@ -34,9 +32,7 @@ class DateFormat(BaseModel):

full: DateTimePattern
year_only: DateTimePattern

class Config:
arbitrary_types_allowed = True # No validator for `DateTimePattern`
model_config = ConfigDict(arbitrary_types_allowed=True)


class Theme(BaseModel):
Expand Down
Loading

0 comments on commit 36ca4a5

Please sign in to comment.