We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thought I'd give the new Literal a whirl and stumbled on this:
Literal
In [1]: import sys In [2]: sys.platform, sys.version Out[2]: ('darwin', '3.7.2 (default, Mar 1 2019, 12:15:59) \n[Clang 5.0.2 (tags/RELEASE_502/final)]') In [3]: import pydantic In [4]: pydantic.VERSION Out[4]: StrictVersion ('0.30') In [5]: from typing_extensions import Literal In [6]: class Foo(pydantic.BaseModel): ...: bar: Literal['baz'] ...: In [7]: Foo.schema() --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-7-0d83fa816939> in <module> ----> 1 Foo.schema() ~/code/xyz/.venv/lib/python3.7/site-packages/pydantic/main.py in schema(cls, by_alias) 461 if cached is not None: 462 return cached --> 463 s = model_schema(cls, by_alias=by_alias) 464 cls._schema_cache[by_alias] = s 465 return s ~/code/xyz/.venv/lib/python3.7/site-packages/pydantic/schema.py in model_schema(model, by_alias, ref_prefix) 233 model_name = model_name_map[model] 234 m_schema, m_definitions, nested_models = model_process_schema( --> 235 model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix 236 ) 237 if model_name in nested_models: ~/code/xyz/.venv/lib/python3.7/site-packages/pydantic/schema.py in model_process_schema(model, by_alias, model_name_map, ref_prefix, known_models) 551 known_models.add(model) 552 m_schema, m_definitions, nested_models = model_type_schema( --> 553 model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, known_models=known_models 554 ) 555 s.update(m_schema) ~/code/xyz/.venv/lib/python3.7/site-packages/pydantic/schema.py in model_type_schema(model, by_alias, model_name_map, ref_prefix, known_models) 579 try: 580 f_schema, f_definitions, f_nested_models = field_schema( --> 581 f, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, known_models=known_models 582 ) 583 except SkipField as skip: ~/code/xyz/.venv/lib/python3.7/site-packages/pydantic/schema.py in field_schema(field, by_alias, model_name_map, ref_prefix, known_models) 292 schema_overrides=schema_overrides, 293 ref_prefix=ref_prefix, --> 294 known_models=known_models or set(), 295 ) 296 # $ref will only be returned when there are no schema_overrides ~/code/xyz/.venv/lib/python3.7/site-packages/pydantic/schema.py in field_type_schema(field, by_alias, model_name_map, schema_overrides, ref_prefix, known_models) 522 schema_overrides=schema_overrides, 523 ref_prefix=ref_prefix, --> 524 known_models=known_models, 525 ) 526 definitions.update(f_definitions) ~/code/xyz/.venv/lib/python3.7/site-packages/pydantic/schema.py in field_singleton_schema(field, by_alias, model_name_map, schema_overrides, ref_prefix, known_models) 743 if field.schema is not None and field.schema.const: 744 f_schema['const'] = field.default --> 745 if issubclass(field.type_, Enum): 746 f_schema.update({'enum': [item.value for item in field.type_]}) 747 # Don't return immediately, to allow adding specific types TypeError: issubclass() arg 1 must be a class
The text was updated successfully, but these errors were encountered:
This same issue comes up for NewType as well. I'll take a look at this tonight.
NewType
Sorry, something went wrong.
18d4b2b
Serialization return schema (pydantic#646)
ebf07a0
No branches or pull requests
Bug
Thought I'd give the new
Literal
a whirl and stumbled on this:The text was updated successfully, but these errors were encountered: