NowanIlfideme / pydantic-yaml

YAML support for Pydantic models
MIT License
131 stars 10 forks source link

1.3.0 breaks public interface for parse_yaml_raw_as #153

Closed mshonichev closed 3 months ago

mshonichev commented 3 months ago

After recent changes as of 1.3.0 release, the following

Example:

from pydantic_yaml.loader import T, parse_yaml_raw_as

started failing with the following

Backtrace:

ImportError: cannot import name 'T' from 'pydantic_yaml.loader' (/home/user/tests/.venv/lib/python3.10/site-packages/pydantic_yaml/loader.py)

I suppose as parse_yaml_raw_as is a generic function, the TypeVar it uses is a part of its public interface.

Or is it not?

I'm not sure, can you provide me some hints here?

mshonichev commented 3 months ago

well, actually, shame on me

I've replaced

from pydantic_yaml.loader import T, parse_yaml_raw_as

to

from pydantic import BaseModel
from pydantic_yaml import parse_yaml_raw_as, to_yaml_str

T = TypeVar("T", bound=BaseModel)

and everything seems to be working just fine, even mypy check is passed.

I guess issues is not an issue anyway)