Repository: pydantic/pydantic

Issue:
1.9.0a1  breaks workaround for `field_type_schema` and nullable
release 1.9.0a1  breaks this work around completely:

```python
.../inmanta/data/model.py", line 34, in <module>
    old_field_type_schema = pydantic.schema.field_type_schema
AttributeError: 'cython_function_or_method' object has no attribute 'field_type_schema'
```

_Originally posted by @wouterdb in https://github.com/samuelcolvin/pydantic/issues/1270#issuecomment-997700804_


Discussion:
I think this issue has the following root cause:

* The `pydantic/main.py` file defines a function called `schema`
* The `pydantic/__init__.py` file does the import `from .main import *`

As such the following import `import pydantic.schema` imports the function `schema` and not the package `schema` which also exists in the `pydantic` package.

Illustration:
```
(env) [arnaud@laptop]/tmp% pip install pydantic==1.8.2
...
Successfully installed pydantic-1.8.2
(env) [arnaud@laptop]/tmp% python
>>> import pydantic.schema
>>> print(pydantic.schema)
<module 'pydantic.schema' from '/tmp/env/lib64/python3.6/site-packages/pydantic/schema.cpython-36m-x86_64-linux-gnu.so'>

(env) [arnaud@laptop]/tmp% pip install -U --pre pydantic
...
Successfully installed pydantic-1.9.0a1
(env) [arnaud@laptop]/tmp% python                       
>>> import pydantic.schema
>>> print(pydantic.schema)
<cyfunction schema at 0x7fccff445d50>
```

Resolving patch:
diff --git a/docs/examples/schema_ad_hoc.py b/docs/examples/schema_ad_hoc.py
--- a/docs/examples/schema_ad_hoc.py
+++ b/docs/examples/schema_ad_hoc.py
@@ -2,7 +2,7 @@
 
 from typing_extensions import Annotated
 
-from pydantic import BaseModel, Field, schema_json
+from pydantic import BaseModel, Field, schema_json_of
 
 
 class Cat(BaseModel):
@@ -17,4 +17,4 @@ class Dog(BaseModel):
 
 Pet = Annotated[Union[Cat, Dog], Field(discriminator='pet_type')]
 
-print(schema_json(Pet, title='The Pet Schema', indent=2))
+print(schema_json_of(Pet, title='The Pet Schema', indent=2))
diff --git a/pydantic/__init__.py b/pydantic/__init__.py
--- a/pydantic/__init__.py
+++ b/pydantic/__init__.py
@@ -67,8 +67,8 @@
     'parse_file_as',
     'parse_obj_as',
     'parse_raw_as',
-    'schema',
-    'schema_json',
+    'schema_of',
+    'schema_json_of',
     # types
     'NoneStr',
     'NoneBytes',
diff --git a/pydantic/tools.py b/pydantic/tools.py
--- a/pydantic/tools.py
+++ b/pydantic/tools.py
@@ -7,7 +7,7 @@
 from .types import StrBytes
 from .typing import display_as_type
 
-__all__ = ('parse_file_as', 'parse_obj_as', 'parse_raw_as', 'schema', 'schema_json')
+__all__ = ('parse_file_as', 'parse_obj_as', 'parse_raw_as', 'schema_of', 'schema_json_of')
 
 NameFactory = Union[str, Callable[[Type[Any]], str]]
 
@@ -82,11 +82,11 @@ def parse_raw_as(
     return parse_obj_as(type_, obj, type_name=type_name)
 
 
-def schema(type_: Any, *, title: Optional[NameFactory] = None, **schema_kwargs: Any) -> 'DictStrAny':
+def schema_of(type_: Any, *, title: Optional[NameFactory] = None, **schema_kwargs: Any) -> 'DictStrAny':
     """Generate a JSON schema (as dict) for the passed model or dynamically generated one"""
     return _get_parsing_type(type_, type_name=title).schema(**schema_kwargs)
 
 
-def schema_json(type_: Any, *, title: Optional[NameFactory] = None, **schema_json_kwargs: Any) -> str:
+def schema_json_of(type_: Any, *, title: Optional[NameFactory] = None, **schema_json_kwargs: Any) -> str:
     """Generate a JSON schema (as JSON) for the passed model or dynamically generated one"""
     return _get_parsing_type(type_, type_name=title).schema_json(**schema_json_kwargs)


Test patch:
diff --git a/tests/test_tools.py b/tests/test_tools.py
--- a/tests/test_tools.py
+++ b/tests/test_tools.py
@@ -5,7 +5,7 @@
 
 from pydantic import BaseModel, ValidationError
 from pydantic.dataclasses import dataclass
-from pydantic.tools import parse_file_as, parse_obj_as, parse_raw_as, schema, schema_json
+from pydantic.tools import parse_file_as, parse_obj_as, parse_raw_as, schema_json_of, schema_of
 
 
 @pytest.mark.parametrize('obj,type_,parsed', [('1', int, 1), (['1'], List[int], [1])])
@@ -101,11 +101,11 @@ class Item(BaseModel):
 
 
 def test_schema():
-    assert schema(Union[int, str], title='IntOrStr') == {
+    assert schema_of(Union[int, str], title='IntOrStr') == {
         'title': 'IntOrStr',
         'anyOf': [{'type': 'integer'}, {'type': 'string'}],
     }
-    assert schema_json(Union[int, str], title='IntOrStr', indent=2) == (
+    assert schema_json_of(Union[int, str], title='IntOrStr', indent=2) == (
         '{\n'
         '  "title": "IntOrStr",\n'
         '  "anyOf": [\n'