-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: upgrade to pydantic v2 #86
Conversation
guppy/hugr/tys.py
Outdated
class Sum(ABC, BaseModel): | ||
"""Sum type, variants are tagged by their position in the type row""" | ||
# class Sum(ABC, BaseModel): | ||
# """Sum type, variants are tagged by their position in the type row""" | ||
|
||
t: Literal["Sum"] = "Sum" | ||
# t: Literal["Sum"] = "Sum" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably delete this
guppy/hugr/tys.py
Outdated
SumUnion = UnitSum | GeneralSum | ||
Sum = Annotated[SumUnion, Field(discriminator="s")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you define the alias SumUnion
instead of inlining it below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to use it in in the isinstance check (annotated unions don't work)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got rid of it
guppy/hugr/tys.py
Outdated
@@ -24,7 +23,7 @@ class TypeParam(BaseModel): | |||
|
|||
class BoundedNatParam(BaseModel): | |||
tp: Literal["BoundedNat"] = "BoundedNat" | |||
bound: int | None | |||
bound: int | None = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this default needed for deserialisation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the migration code added it automatically (bump_pydantic)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'd remove it then (so that you have to make a conscious choice when passing None
)
d7e1a41
to
12ee66c
Compare
12ee66c
to
33a7a50
Compare
guppy/hugr/tys.py
Outdated
@@ -24,7 +23,7 @@ class TypeParam(BaseModel): | |||
|
|||
class BoundedNatParam(BaseModel): | |||
tp: Literal["BoundedNat"] = "BoundedNat" | |||
bound: int | None | |||
bound: int | None = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'd remove it then (so that you have to make a conscious choice when passing None
)
guppy/hugr/val.py
Outdated
@@ -18,7 +18,7 @@ class FunctionVal(BaseModel): | |||
"""A higher-order function value.""" | |||
|
|||
v: Literal["Function"] = "Function" | |||
hugr: Any # TODO | |||
hugr: Any = None # TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
c10daee
to
c022c71
Compare
No description provided.