Skip to content

Commit 3fd4553

Browse files
test: add check for enum import with pydantic==2.6.1 (#723)
Co-authored-by: Leon Haffmans <leon.haffmans@hochfrequenz.de>
1 parent 8909b66 commit 3fd4553

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/bo4e/utils/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,9 @@
55
from typing import TypeVar
66

77
from pydantic import BaseModel
8-
from pydantic._internal._fields import PydanticGeneralMetadata
9-
from pydantic.fields import FieldInfo
108

119
from ..version import __gh_version__
1210

13-
14-
def is_constrained_str(model_field: FieldInfo) -> bool:
15-
"""
16-
returns True if the given model_field is a constrained string
17-
"""
18-
for metad in model_field.metadata:
19-
if isinstance(metad, PydanticGeneralMetadata):
20-
if hasattr(metad, "pattern"):
21-
return True
22-
return False
23-
# return isinstance(model_field.outer_type_, type) and issubclass(model_field.outer_type_, str)
24-
25-
2611
T = TypeVar("T", bound=BaseModel)
2712

2813

tests/test_import_enum.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class TestImport:
2+
def test_importing_an_enum(self) -> None:
3+
"""
4+
checks that importing an enum works
5+
"""
6+
from bo4e import Vertragsstatus # pylint: disable=import-outside-toplevel,unused-import
7+
8+
assert True

0 commit comments

Comments
 (0)