Repository: pydantic/pydantic

Issue:
NameError: name 'SchemaExtraCallable' is not defined
# 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']
```

```py
>>> 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 :slightly_smiling_face: 


Discussion:

Resolving patch:
diff --git a/pydantic/main.py b/pydantic/main.py
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -66,6 +66,10 @@ def __call__(self, schema: Dict[str, Any], model_class: Type['Model']) -> None:
             pass
 
 
+else:
+    SchemaExtraCallable = Callable[..., None]
+
+
 try:
     import cython  # type: ignore
 except ImportError:


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -1,6 +1,6 @@
 import sys
 from enum import Enum
-from typing import Any, Callable, ClassVar, Dict, List, Mapping, Optional, Type
+from typing import Any, Callable, ClassVar, Dict, List, Mapping, Optional, Type, get_type_hints
 from uuid import UUID, uuid4
 
 import pytest
@@ -1119,3 +1119,10 @@ class Model2(BaseModel):
         Model1.parse_obj({})
     with pytest.raises(ValidationError):
         Model2.parse_obj({})
+
+
+def test_base_config_type_hinting():
+    class M(BaseModel):
+        a: int
+
+    get_type_hints(M.__config__)