Skip to content

Commit

Permalink
fix two mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesturk committed Nov 24, 2023
1 parent 9986f4c commit d654db7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scrapeghost/scrapers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(

if use_pydantic:
# check if schema is a pydantic model
if not issubclass(schema, BaseModel):
if not isinstance(schema, type) or not issubclass(schema, BaseModel):
raise ValueError("Schema must be a Pydantic model.")
self.postprocessors.append(PydanticPostprocessor(schema))

Expand Down Expand Up @@ -242,7 +242,9 @@ def _pydantic_to_simple_schema(pydantic_model: Type[BaseModel]) -> dict:
schema: dict = {}
for field_name, field in pydantic_model.model_fields.items():
# model_fields is present on Pydantic models, so can process recursively
if hasattr(field.annotation, "model_fields"):
if field.annotation is None:
raise TypeError("missing annotation")
elif issubclass(field.annotation, BaseModel):
schema[field_name] = _pydantic_to_simple_schema(field.annotation)
else:
type_name = field.annotation.__name__
Expand Down

0 comments on commit d654db7

Please sign in to comment.