Minimal example below results in TypeError: issubclass() arg 1 must be a class
. Not being a Pydantic/FastAPI user, I haven’t found any particularly helpful explanation for what’s going on.
from __future__ import annotations
from abc import ABC, abstractmethod
from flow import flow
class SomeAbstractBaseClass(ABC):
def __init__(self) -> None:
pass
@abstractmethod
def run(self) -> int:
return 1
class SomeImplementation(SomeAbstractBaseClass):
def __init__(self) -> None:
super().__init__()
def run(self) -> int:
return 2
@flow
def job(regular_arg: int, some_object: SomeImplementation) -> None:
print(regular_arg)
print(some_object)
@flow(name="master_flow")
def master_flow():
job(1, SomeImplementation())
if __name__ == "__main__":
master_flow()
Results in the following traceback:
Traceback (most recent call last):
File "/Users/usr/Documents/Code/data-quality/src/flow_2.py", line 26, in <module>
def job(regular_arg: int, some_object: SomeImplementation) -> None:
File "/Users/usr/miniconda3/envs/dev/lib/python3.10/site-packages/prefect/flows.py", line 631, in flow
Flow(
File "/Users/usr/miniconda3/envs/dev/lib/python3.10/site-packages/prefect/context.py", line 176, in __register_init__
__init__(__self__, *args, **kwargs)
File "/Users/usr/miniconda3/envs/dev/lib/python3.10/site-packages/prefect/flows.py", line 175, in __init__
self.parameters = parameter_schema(self.fn)
File "/Users/usr/miniconda3/envs/dev/lib/python3.10/site-packages/prefect/utilities/callables.py", line 201, in parameter_schema
pydantic.create_model(
File "pydantic/main.py", line 665, in pydantic.main.BaseModel.schema
File "pydantic/schema.py", line 187, in pydantic.schema.model_schema
File "pydantic/schema.py", line 581, in pydantic.schema.model_process_schema
File "pydantic/schema.py", line 622, in pydantic.schema.model_type_schema
File "pydantic/schema.py", line 255, in pydantic.schema.field_schema
File "pydantic/schema.py", line 527, in pydantic.schema.field_type_schema
File "pydantic/schema.py", line 924, in pydantic.schema.field_singleton_schema
File "/Users/usr/miniconda3/envs/dev/lib/python3.10/abc.py", line 123, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class