Skip to content

Commit

Permalink
Add support for pydantic v2 (#1577)
Browse files Browse the repository at this point in the history
* Add support for pydantic v2
* Use pydantic v1 internally
  • Loading branch information
guarin authored Jul 10, 2024
1 parent 454ad06 commit 6ebde88
Show file tree
Hide file tree
Showing 309 changed files with 2,694 additions and 558 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, constr, validator
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/datasets_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictInt, StrictStr, conint, conlist, constr, validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictStr, conint, constr, validator
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/docker_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictStr, conint, conlist, constr, validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, constr, validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictStr, constr, validator
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/jobs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictStr
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/mappings_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictStr, conint, constr, validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, constr, validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, conint, conlist, constr, validator
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/quota_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated


Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/samples_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictStr, conint, constr, validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, constr, validator
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/scores_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, conint, constr, validator
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/tags_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictInt, StrictStr, conint, constr, validator
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api/teams_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictStr, constr, validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
try:
# Pydantic >=v1.10.17
from pydantic.v1 import validate_arguments, ValidationError
except ImportError:
# Pydantic v1
from pydantic import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import StrictStr
Expand Down
7 changes: 6 additions & 1 deletion lightly/openapi_generated/swagger_client/api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from __future__ import annotations
from typing import Any, Dict, Optional
from pydantic import Field, StrictInt, StrictStr
try:
# Pydantic >=v1.10.17
from pydantic.v1 import Field, StrictInt, StrictStr
except ImportError:
# Pydantic v1
from pydantic import Field, StrictInt, StrictStr

class ApiResponse:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@


from typing import List, Union
from pydantic import Extra, BaseModel, Field, StrictFloat, StrictInt, conlist, constr, validator
try:
# Pydantic >=v1.10.17
from pydantic.v1 import BaseModel, Field, StrictFloat, StrictInt, conlist, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.
except ImportError:
# Pydantic v1
from pydantic import BaseModel, Field, StrictFloat, StrictInt, conlist, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.

class ActiveLearningScoreCreateRequest(BaseModel):
"""
Expand All @@ -42,7 +49,7 @@ class Config:
allow_population_by_field_name = True
validate_assignment = True
use_enum_values = True
extra = Extra.forbid
extra = "forbid"

def to_str(self, by_alias: bool = False) -> str:
"""Returns the string representation of the model"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@


from typing import List, Union
from pydantic import Extra, BaseModel, Field, StrictFloat, StrictInt, conint, conlist, constr, validator
try:
# Pydantic >=v1.10.17
from pydantic.v1 import BaseModel, Field, StrictFloat, StrictInt, conint, conlist, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.
except ImportError:
# Pydantic v1
from pydantic import BaseModel, Field, StrictFloat, StrictInt, conint, conlist, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.

class ActiveLearningScoreData(BaseModel):
"""
Expand Down Expand Up @@ -59,7 +66,7 @@ class Config:
allow_population_by_field_name = True
validate_assignment = True
use_enum_values = True
extra = Extra.forbid
extra = "forbid"

def to_str(self, by_alias: bool = False) -> str:
"""Returns the string representation of the model"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@



from pydantic import Extra, BaseModel, Field, conint, constr, validator
try:
# Pydantic >=v1.10.17
from pydantic.v1 import BaseModel, Field, conint, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.
except ImportError:
# Pydantic v1
from pydantic import BaseModel, Field, conint, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.

class ActiveLearningScoreTypesV2Data(BaseModel):
"""
Expand Down Expand Up @@ -67,7 +74,7 @@ class Config:
allow_population_by_field_name = True
validate_assignment = True
use_enum_values = True
extra = Extra.forbid
extra = "forbid"

def to_str(self, by_alias: bool = False) -> str:
"""Returns the string representation of the model"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@


from typing import List, Union
from pydantic import Extra, BaseModel, Field, StrictFloat, StrictInt, conint, conlist, constr, validator
try:
# Pydantic >=v1.10.17
from pydantic.v1 import BaseModel, Field, StrictFloat, StrictInt, conint, conlist, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.
except ImportError:
# Pydantic v1
from pydantic import BaseModel, Field, StrictFloat, StrictInt, conint, conlist, constr, validator
pass # Add pass to avoid empty try/except if no imports are generated for this file.

class ActiveLearningScoreV2Data(BaseModel):
"""
Expand Down Expand Up @@ -68,7 +75,7 @@ class Config:
allow_population_by_field_name = True
validate_assignment = True
use_enum_values = True
extra = Extra.forbid
extra = "forbid"

def to_str(self, by_alias: bool = False) -> str:
"""Returns the string representation of the model"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@



from pydantic import Extra, BaseModel, Field
try:
# Pydantic >=v1.10.17
from pydantic.v1 import BaseModel, Field
pass # Add pass to avoid empty try/except if no imports are generated for this file.
except ImportError:
# Pydantic v1
from pydantic import BaseModel, Field
pass # Add pass to avoid empty try/except if no imports are generated for this file.
from lightly.openapi_generated.swagger_client.models.task_annotation_savings import TaskAnnotationSavings

class AnnotationSavings(BaseModel):
Expand All @@ -37,7 +44,7 @@ class Config:
allow_population_by_field_name = True
validate_assignment = True
use_enum_values = True
extra = Extra.forbid
extra = "forbid"

def to_str(self, by_alias: bool = False) -> str:
"""Returns the string representation of the model"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
from aenum import no_arg # type: ignore



try:
# Pydantic >=v1.10.17

pass # Add pass to avoid empty try/except if no imports are generated for this file.
except ImportError:
# Pydantic v1

pass # Add pass to avoid empty try/except if no imports are generated for this file.


class ApiErrorCode(str, Enum):
Expand Down
Loading

0 comments on commit 6ebde88

Please sign in to comment.