TypeError: issubclass() arg 1 must be a class
See original GitHub issueBug
Getting issubcluss error on /docs in Fastapi
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
pydantic version: 1.4
pydantic compiled: False
install path: /Users/philippk/anaconda3/envs/py37/lib/python3.7/site-packages/pydantic
python version: 3.7.3 | packaged by conda-forge | (default, Dec 6 2019, 08:36:57) [Clang 9.0.0 (tags/RELEASE_900/final)]
platform: Darwin-19.2.0-x86_64-i386-64bit
optional deps. installed: ['typing-extensions']
(py37) ZG00021:se-sestimate philippk$ docker run -it -p 80:80 -e ENVKEY -e SNOWFLAKE_PASSWORD='dummy' -e SNOWFLAKE_ACCOUNT='zillow' -e SNOWFLAKE_USER='philippk' -e SNOWFLAKE_WAREHOUSE='LOOKER_WH' -e SNOWFLAKE_DATABASE='FEATURESTORE' -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_SECURITY_TOKEN --entrypoint /bin/bash se-sestimate:local-api
root@d50a194c1238:/app# python -c "import pydantic.utils; print(pydantic.utils.version_info())"
pydantic version: 1.4
pydantic compiled: True
install path: /usr/local/lib/python3.7/site-packages/pydantic
python version: 3.7.4 (default, Sep 12 2019, 15:40:15) [GCC 8.3.0]
platform: Linux-4.19.76-linuxkit-x86_64-with-debian-10.1
optional deps. installed: []
Here is the code of request_models:
from typing import List
from pydantic import BaseModel
from enum import Enum
from datetime import date
class ModelName(str, Enum):
repeated_sale = "repeated_sale"
main = "main"
dummy = "dummy"
class Inference(BaseModel):
price: int
model: ModelName
model_version: float
date: date
@app.get("/infer", response_model=Inference)
def infer(
params: dict,
model: ModelName,
v: Optional[float] = None,
date: Optional["date"] = None,
) -> Inference:
"""attempts to pull predictions from snowflake"""
result = app.model_registry.pull(model=model, v=v, date=date).predict(params)
return {"model": model, "v": v, **result}
this results in:
File "/Users/philippk/anaconda3/envs/py37/lib/python3.7/site-packages/pydantic/schema.py", line 657, in field_singleton_schema
if issubclass(field_type, Enum):
TypeError: issubclass() arg 1 must be a class
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:13 (4 by maintainers)
Top Results From Across the Web
issubclass() arg 1 must be a class - Stack Overflow
classinfo may be a tuple of class objects, in which case every entry in classinfo will be checked. In any other case, a...
Read more >TypeError: issubclass() arg 1 must be a class #1298 - GitHub
I'm not sure whether the problem should be considered to lie in fastapi or pydantic, but it appears to be stemming from an...
Read more >[traceback] "TypeError: issubclass() arg 1 must be a class" in ...
I think we should fix "is_valid_model_class" to check a pre-generated list of models and not do a bunch of potentially fail-heavy computery. This...
Read more >6423 (technical_500_response fails on String Exceptions)
... line 77, in technical_500_response if issubclass(exc_type, TemplateDoesNotExist): TypeError: issubclass() arg 1 must be a class ...
Read more >tiangolo/fastapi - Gitter
... in pydantic.validators.find_validators TypeError: issubclass() arg 1 must be a class During handling of the above exception, another exception occurred: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just experience the same bug. update_forward_refs does not solve it.
Simple example of the issue. Try to access /docs on FastAPI