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

rename _types to be public #240

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
rename _types to be public
  • Loading branch information
MatthijsKok committed Sep 14, 2022
commit 1b23bd0889a28d6e148eebdd29355c1d689fada8
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ make install
That should be it, the example shown above should now run.

You might find it useful to look at [`pydantic_core/_pydantic_core.pyi`](./pydantic_core/_pydantic_core.pyi) and
[`pydantic_core/_types.py`](./pydantic_core/_types.py) for more information on the python API,
[`pydantic_core/schema_types.py`](./pydantic_core/schema_types.py) for more information on the python API,
beyond that, [`tests/`](./tests) provide a large number of examples of usage.

If you want to contribute to pydantic-core, you'll want to use some other make commands:
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::Command;
use std::str::from_utf8;

fn generate_self_schema() {
println!("cargo:rerun-if-changed=pydantic_core/_types.py");
println!("cargo:rerun-if-changed=pydantic_core/schema_types.py");
println!("cargo:rerun-if-changed=generate_self_schema.py");
if Path::new("./src/self_schema.py").exists() && option_env!("DEBIAN_FRONTEND") == Some("noninteractive") {
// self_schema.py already exists and DEBIAN_FRONTEND indicates we're in a maturin build,
Expand Down
8 changes: 4 additions & 4 deletions generate_self_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This script generates the schema for the schema - e.g.
a definition of what inputs can be provided to `SchemaValidator()`.

The schema is generated from `pydantic_core/_types.py`.
The schema is generated from `pydantic_core/schema_types.py`.
"""
import importlib.util
import re
Expand All @@ -25,8 +25,8 @@ def get_origin(t):
THIS_DIR = Path(__file__).parent
SAVE_PATH = THIS_DIR / 'src' / 'self_schema.py'

# can't import _types.py directly as pydantic-core might not be installed
core_types_spec = importlib.util.spec_from_file_location('_typing', str(THIS_DIR / 'pydantic_core' / '_types.py'))
# can't import schema_types.py directly as pydantic-core might not be installed
core_types_spec = importlib.util.spec_from_file_location('_typing', str(THIS_DIR / 'pydantic_core' / 'schema_types.py'))
core_types = importlib.util.module_from_spec(core_types_spec)
core_types_spec.loader.exec_module(core_types)

Expand Down Expand Up @@ -140,7 +140,7 @@ def eval_forward_ref(type_):

def main():
schema_union = core_types.Schema
assert get_origin(schema_union) is Union, 'expected pydantic_core._types.Schema to be a union'
assert get_origin(schema_union) is Union, 'expected pydantic_core.schema_types.Schema to be a union'

schema = {
'type': 'tagged-union',
Expand Down
2 changes: 1 addition & 1 deletion pydantic_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._pydantic_core import PydanticValueError, SchemaError, SchemaValidator, ValidationError, __version__
from ._types import Config, Schema
from .schema_types import Config, Schema

__all__ = '__version__', 'Config', 'Schema', 'SchemaValidator', 'SchemaError', 'ValidationError', 'PydanticValueError'
2 changes: 1 addition & 1 deletion pydantic_core/_pydantic_core.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from typing import Any, TypedDict

from pydantic_core._types import Config, Schema
from pydantic_core.schema_types import Config, Schema

if sys.version_info < (3, 11):
from typing_extensions import NotRequired
Expand Down
File renamed without changes.