A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pydantic/pydantic/issues/545 below:

issubclass() arg 1 must be a class · Issue #545 · pydantic/pydantic · GitHub

Bug

Hi. I'm getting a type error when trying to generate a schema, using fastapi:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 368, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/local/lib/python3.7/site-packages/starlette/applications.py", line 133, in __call__
    await self.error_middleware(scope, receive, send)
  File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 122, in __call__
    raise exc from None
  File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 100, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.7/site-packages/starlette/middleware/cors.py", line 76, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 73, in __call__
    raise exc from None
  File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 62, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 585, in __call__
    await route(scope, receive, send)
  File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 207, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 40, in app
    response = await func(request)
  File "/usr/local/lib/python3.7/site-packages/fastapi/applications.py", line 90, in openapi
    return JSONResponse(self.openapi())
  File "/usr/local/lib/python3.7/site-packages/fastapi/applications.py", line 82, in openapi
    openapi_prefix=self.openapi_prefix,
  File "/usr/local/lib/python3.7/site-packages/fastapi/openapi/utils.py", line 248, in get_openapi
    flat_models=flat_models, model_name_map=model_name_map
  File "/usr/local/lib/python3.7/site-packages/fastapi/utils.py", line 42, in get_model_definitions
    model, model_name_map=model_name_map, ref_prefix=REF_PREFIX
  File "/usr/local/lib/python3.7/site-packages/pydantic/schema.py", line 511, in model_process_schema
    model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix
  File "/usr/local/lib/python3.7/site-packages/pydantic/schema.py", line 537, in model_type_schema
    f, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix
  File "/usr/local/lib/python3.7/site-packages/pydantic/schema.py", line 274, in field_schema
    ref_prefix=ref_prefix,
  File "/usr/local/lib/python3.7/site-packages/pydantic/schema.py", line 486, in field_type_schema
    ref_prefix=ref_prefix,
  File "/usr/local/lib/python3.7/site-packages/pydantic/schema.py", line 687, in field_singleton_schema
    if issubclass(field.type_, Enum):
TypeError: issubclass() arg 1 must be a class

For bugs/questions:

Where possible please include a self contained code snippet describing your
bug, question, or where applicable feature request:

from __future__ import annotations
from typing import Optional, List

from pydantic import BaseModel, UUID4


class CategoryCreationValidator(BaseModel):
    name: str = ...
    labels: List[str] = None
    description: str = ...
    parent_id: int = None


class CategorySelectionValidator(BaseModel):
    name: str = ...
    organization_id: str = ...
    labels: Optional[str] = None
    description: str = ...
    parent_id: Optional[int] = None


class CategoryUpdateValidator(BaseModel):
    name: Optional[str] = None
    organization_id: Optional[str] = None
    labels: Optional[List[str]] = None
    description: Optional[str] = None
    parent_id: Optional[int] = None


class ClusterValidator(BaseModel):
    name: str = ...
    category_id: Optional[str] = None


class CategoryModel(BaseModel):
    id: int = ...
    name: str = ...
    description: str = ...
    parent_id: int = None
    children: List[CategoryModel]


#CategoryModel.update_forward_refs()


class ClusterModel(BaseModel):
    id: UUID4 = ...
    name: str = ...
    parent_category_id: str = ...
    queries: List[str] = ...
    urls: List[str] = ...


class SuggestionValidator(BaseModel):
    queries: List[str] = ...
    urls: List[str] = ...


class QueryCreationValidator(BaseModel):
    query_text: str = ...
    cluster_id: UUID4 = ...


class QuerySelectionValidator(BaseModel):
    cluster_id: UUID4 = ...


class UrlCreationValidator(BaseModel):
    url: str = ...
    cluster_id: UUID4 = ...


class UrlSelectionValidator(BaseModel):
    cluster_id: UUID4 = ...


class CreateClusterInput(BaseModel):
    name: str = ...
    category_id: int = ...


class ClusterSelectionValidator(BaseModel):
    category_name: str = ...

...

xinthose, smhtbtb, sontl, stazz, richarddwang and 2 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4