Skip to content

TypeError: issubclass() arg 1 must be a class for a Pattern Field #1767

@ojomio

Description

@ojomio

Bug

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.5.1
            pydantic compiled: False
                 install path: /home/yury/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic
               python version: 3.6.9 (default, Jul 17 2020, 12:50:27)  [GCC 8.4.0]
                     platform: Linux-5.3.0-62-generic-x86_64-with-Ubuntu-18.04-bionic
     optional deps. installed: ['typing-extensions', 'email-validator']
from pydantic import BaseModel                                                                                                                                                                      
from pydantic.schema import model_process_schema
from typing import Pattern

class Test(BaseModel): 
    f : Pattern

model_process_schema(Test, model_name_map={})                                                                                                                                                      
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-c3756917c641> in <module>
----> 1 model_process_schema(Test, model_name_map={})

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in model_process_schema(model, by_alias, model_name_map, ref_prefix, known_models)
    454     known_models.add(model)
    455     m_schema, m_definitions, nested_models = model_type_schema(
--> 456         model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, known_models=known_models
    457     )
    458     s.update(m_schema)

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in model_type_schema(model, by_alias, model_name_map, ref_prefix, known_models)
    490         try:
    491             f_schema, f_definitions, f_nested_models = field_schema(
--> 492                 f, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, known_models=known_models
    493             )
    494         except SkipField as skip:

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in field_schema(field, by_alias, model_name_map, ref_prefix, known_models)
    189         schema_overrides=schema_overrides,
    190         ref_prefix=ref_prefix,
--> 191         known_models=known_models or set(),
    192     )
    193     # $ref will only be returned when there are no schema_overrides

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in field_type_schema(field, by_alias, model_name_map, schema_overrides, ref_prefix, known_models)
    416             schema_overrides=schema_overrides,
    417             ref_prefix=ref_prefix,
--> 418             known_models=known_models,
    419         )
    420         definitions.update(f_definitions)

~/.cache/pypoetry/virtualenvs/chatbot-py3.6/lib/python3.6/site-packages/pydantic/schema.py in field_singleton_schema(field, by_alias, model_name_map, schema_overrides, ref_prefix, known_models)
    642         f_schema['const'] = literal_value
    643 
--> 644     if issubclass(field_type, Enum):
    645         f_schema.update({'enum': [item.value for item in field_type]})
    646         # Don't return immediately, to allow adding specific types

TypeError: issubclass() arg 1 must be a class

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions