Skip to content
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

Update Pydantic to v2 #26

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions buenavista/http/schemas.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Dict, List, Optional


from pydantic import BaseModel, HttpUrl
from pydantic import BaseModel, ConfigDict, HttpUrl


def camel_case(s: str) -> str:
Expand All @@ -10,9 +10,10 @@ def camel_case(s: str) -> str:


class CamelModel(BaseModel):
class Config:
alias_generator = camel_case
allow_population_by_field_name = True
model_config = ConfigDict(
alias_generator=camel_case,
populate_by_name=True,
)


class ClientTypeSignatureParameter(CamelModel):
Expand Down Expand Up @@ -57,11 +58,11 @@ class StatementStats(CamelModel):


class QueryError(CamelModel):
message: Optional[str]
sql_state: Optional[str]
message: Optional[str] = None
sql_state: Optional[str] = None
Comment on lines +61 to +62
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwills I can't know if this was intentional or not since you do have some Optional[...] fields with a None default value. I blindly added None as a default to all fields that had failing tests because of missing values but maybe that's not what you want.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah it was just laziness— thank you!

error_code: int
error_name: Optional[str]
error_type: Optional[str]
error_name: Optional[str] = None
error_type: Optional[str] = None
retriable: bool
error_location: Optional[CamelModel] = None
failure_info: Optional[CamelModel] = None
Expand All @@ -81,7 +82,7 @@ class BaseResult(CamelModel):
id: str
info_uri: HttpUrl
stats: StatementStats
warnings: Optional[List[PrestoWarning]]
warnings: Optional[List[PrestoWarning]] = None


class QueryResult(BaseResult):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
packages=find_namespace_packages(include=["buenavista", "buenavista.*"]),
include_package_data=True,
install_requires=[
"fastapi>=0.80.0,<1.0.0",
"pydantic>=1.2.0,<2.0.0",
"fastapi>=0.109.0,<1.0.0",
"pydantic>=2,<3",
"sqlglot",
],
extras_require={
Expand Down