Closed Redlnn closed 1 year ago
avilla.twilight.twilight 中使用了 from pydantic.utils import Representation
avilla.twilight.twilight
from pydantic.utils import Representation
但 Pydantic V2 中该类已被移动,应使用 from pydantic.v1.utils import Representation
from pydantic.v1.utils import Representation
是否可以这样改呢,这样改的话 Pylance 在环境是 Pydantic V1 时会乱叫,或者有无更优雅的实现?
- from pydantic.utils import Representation + from pydantic.version import VERSION as PYDANTIC_VERSION ... + if int(PYDANTIC_VERSION[0]) >= 2: + from pydantic.v1.utils import Representation + else: + from pydantic.utils import Representation
if TYPE_CHECKING. it really works.
PRs welcome.
and fix the missing dep plz
avilla.twilight.twilight
中使用了from pydantic.utils import Representation
但 Pydantic V2 中该类已被移动,应使用
from pydantic.v1.utils import Representation
是否可以这样改呢,这样改的话 Pylance 在环境是 Pydantic V1 时会乱叫,或者有无更优雅的实现?