Skip to content

Commit

Permalink
avoid ome_types import during build
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jul 1, 2023
1 parent e44f7d8 commit 4cd3a23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ome_autogen/_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
from xsdata_pydantic_basemodel.generator import PydanticBaseFilters

from ome_autogen import _util
from ome_types._mixins._base_type import AUTO_SEQUENCE

if TYPE_CHECKING:
from xsdata.codegen.models import Attr, Class
from xsdata.models.config import GeneratorConfig


# from ome_types._mixins._base_type import AUTO_SEQUENCE
# avoiding import to avoid build-time dependency on the ome-types package
AUTO_SEQUENCE = "__auto_sequence__"


class OmeGenerator(DataclassGenerator):
@classmethod
def init_filters(cls, config: GeneratorConfig) -> Filters:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from _pytest.monkeypatch import MonkeyPatch

import ome_autogen.main
from ome_autogen import _generator
from ome_types._mixins import _base_type


def test_autogen(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
Expand All @@ -21,3 +23,8 @@ def test_autogen(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
mod = importlib.import_module("ome_types.model.ome_2016_06")
assert mod.__file__ and mod.__file__.startswith(str(tmp_path))
assert mod.Channel(color="blue")


def test_autosequence_name() -> None:
"""These should match, but shouldn't be imported from each other."""
assert _generator.AUTO_SEQUENCE == _base_type.AUTO_SEQUENCE

0 comments on commit 4cd3a23

Please sign in to comment.