Skip to content

Commit 689a086

Browse files
hf-kkleinlord-haffi
andcommitted
test: add check for enum import with pydantic==2.6.1 (#723)
Co-authored-by: Leon Haffmans <leon.haffmans@hochfrequenz.de>
1 parent d8e505b commit 689a086

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/bo4e/utils/__init__.py

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

66
from pydantic import BaseModel
7-
from pydantic._internal._fields import PydanticGeneralMetadata
8-
from pydantic.fields import FieldInfo
97

108
from ..version import __gh_version__
119

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

2712

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)