Skip to content

Commit

Permalink
Avoid deprecated Pydantic __fields__ attribute (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
faph authored Jul 29, 2024
2 parents 3def733 + af95dea commit bbc0177
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/py_avro_schema/_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ class PydanticSchema(RecordSchema):
def handles_type(cls, py_type: Type) -> bool:
"""Whether this schema class can represent a given Python class"""
py_type = _type_from_annotated(py_type)
return hasattr(py_type, "__fields__")
return hasattr(py_type, "__pydantic_private__")

def __init__(self, py_type: Type[pydantic.BaseModel], namespace: Optional[str] = None, options: Option = Option(0)):
"""
Expand Down Expand Up @@ -973,7 +973,7 @@ def handles_type(cls, py_type: Type) -> bool:
# Dataclasses are handled above
not dataclasses.is_dataclass(py_type)
# Pydantic models are handled above
and not hasattr(py_type, "__fields__")
and not hasattr(py_type, "__pydantic_private__")
# If we are subclassing a string, used the "named string" approach
and (inspect.isclass(py_type) and not issubclass(py_type, str))
# Any other class with __init__ with typed args
Expand Down

0 comments on commit bbc0177

Please sign in to comment.