Skip to content
New issue

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

NameError: name 'SchemaExtraCallable' is not defined #1614

Closed
pawamoy opened this issue Jun 8, 2020 · 1 comment · Fixed by #1618
Closed

NameError: name 'SchemaExtraCallable' is not defined #1614

pawamoy opened this issue Jun 8, 2020 · 1 comment · Fixed by #1618
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@pawamoy
Copy link

pawamoy commented Jun 8, 2020

Bug

https://github.com/pawamoy/pytkdocs/pull/41/checks?check_run_id=747827745

             pydantic version: 1.5.1
            pydantic compiled: False
                 install path: /home/pawamoy/.cache/pypoetry/virtualenvs/pytkdocs-LMVK1zAi-py3.7/lib/python3.7/site-packages/pydantic
               python version: 3.7.5 (default, Apr 27 2020, 16:40:42)  [GCC 9.3.0]
                     platform: Linux-5.6.15-arch1-1-x86_64-with-arch
     optional deps. installed: ['typing-extensions']
>>> import typing
>>> import pydantic
>>> 
>>> class M(pydantic.BaseModel):
...     a: int
... 
>>> typing.get_type_hints(M.__config__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.5/lib/python3.7/typing.py", line 976, in get_type_hints
    value = _eval_type(value, base_globals, localns)
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.5/lib/python3.7/typing.py", line 265, in _eval_type
    ev_args = tuple(_eval_type(a, globalns, localns) for a in t.__args__)
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.5/lib/python3.7/typing.py", line 265, in <genexpr>
    ev_args = tuple(_eval_type(a, globalns, localns) for a in t.__args__)
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.5/lib/python3.7/typing.py", line 263, in _eval_type
    return t._evaluate(globalns, localns)
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.5/lib/python3.7/typing.py", line 467, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
NameError: name 'SchemaExtraCallable' is not defined

Now you could wonder, "why are you doing this?", and you would be right to do so. Well, I'm writing a package that automatically introspect classes and all their members to output structured data in JSON (it's pytkdocs, used by mkdocstrings to bring autodoc for MkDocs, and pytkdocs tries to support Pydantic models).

I'm just reporting for the sake of it. Maybe there's an easy fix? Maybe it's a bug in Python's typing? Maybe it's expected because SchemaExtraCallable is a forward ref in this context?

Anyway, I'm catching the error for now, so it's fine if you want to close the issue 🙂

@pawamoy pawamoy added the bug V1 Bug related to Pydantic V1.X label Jun 8, 2020
PrettyWood added a commit to PrettyWood/pydantic that referenced this issue Jun 9, 2020
PrettyWood added a commit to PrettyWood/pydantic that referenced this issue Jun 9, 2020
samuelcolvin pushed a commit that referenced this issue Jun 9, 2020
@samuelcolvin
Copy link
Member

Thanks for reporting, @PrettyWood has kindly fixed this for you.

I'll try make a release in the next week or so that includes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants