From 096970a1ac332da46f2175522ee282b977f9e243 Mon Sep 17 00:00:00 2001 From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:04:40 +0000 Subject: [PATCH 1/3] Update Pydantic to v2 --- buenavista/http/schemas.py | 9 +++++---- setup.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/buenavista/http/schemas.py b/buenavista/http/schemas.py index 3731136..0597c38 100644 --- a/buenavista/http/schemas.py +++ b/buenavista/http/schemas.py @@ -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: @@ -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 + allow_population_by_field_name=True + ) class ClientTypeSignatureParameter(CamelModel): diff --git a/setup.py b/setup.py index 3c5f766..4be5fb5 100644 --- a/setup.py +++ b/setup.py @@ -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={ From 92f0077485fc029dd4d0c55902b7322c526ac0ca Mon Sep 17 00:00:00 2001 From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:09:08 +0000 Subject: [PATCH 2/3] fix a couple things --- buenavista/http/schemas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buenavista/http/schemas.py b/buenavista/http/schemas.py index 0597c38..98b8c48 100644 --- a/buenavista/http/schemas.py +++ b/buenavista/http/schemas.py @@ -11,8 +11,8 @@ def camel_case(s: str) -> str: class CamelModel(BaseModel): model_config = ConfigDict( - alias_generator=camel_case - allow_population_by_field_name=True + alias_generator=camel_case, + populate_by_name=True, ) From ede37d2f8a8d6cdb5e6bca26eb7c98f5c4a189ad Mon Sep 17 00:00:00 2001 From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:10:06 +0000 Subject: [PATCH 3/3] add defaults for optionals --- buenavista/http/schemas.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buenavista/http/schemas.py b/buenavista/http/schemas.py index 98b8c48..94c6d65 100644 --- a/buenavista/http/schemas.py +++ b/buenavista/http/schemas.py @@ -58,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 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 @@ -82,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):