Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file.

## 0.4.4

### Fixed

- `import lionweb.language` (and `lionweb.serialization`, `lionweb.self.lioncore`,
`lionweb.generation`) no longer fails with a circular import when it is the
first `lionweb` import in the process. The autoresolve prefix constants moved
to `lionweb.autoresolve`, so `lionweb.model` no longer imports the
`lionweb.utils` package. `lionweb.utils.autoresolve` has been removed.

## 0.4.3

### Changed
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/lionweb/model/classifier_instance_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING, Optional

from lionweb.utils.autoresolve import (
from lionweb.autoresolve import (
LIONCORE_AUTORESOLVE_PREFIX,
LIONCOREBUILTINS_AUTORESOLVE_PREFIX,
)
Expand Down
8 changes: 4 additions & 4 deletions src/lionweb/serialization/node_populator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from typing import TYPE_CHECKING, cast

from lionweb.api.classifier_instance_resolver import ClassifierInstanceResolver
from lionweb.autoresolve import (
LIONCORE_AUTORESOLVE_PREFIX,
LIONCOREBUILTINS_AUTORESOLVE_PREFIX,
)
from lionweb.language.lioncore_builtins import LionCoreBuiltins
from lionweb.lionweb_version import LionWebVersion
from lionweb.model import ClassifierInstance, Node
Expand All @@ -10,10 +14,6 @@
from lionweb.serialization.deserialization_exception import DeserializationException
from lionweb.serialization.deserialization_status import DeserializationStatus
from lionweb.serialization.unavailable_node_policy import UnavailableNodePolicy
from lionweb.utils.autoresolve import (
LIONCORE_AUTORESOLVE_PREFIX,
LIONCOREBUILTINS_AUTORESOLVE_PREFIX,
)


class NodePopulator:
Expand Down
45 changes: 45 additions & 0 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import subprocess
import sys
import unittest

SRC_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src")

MODULES = [
"lionweb",
"lionweb.api",
"lionweb.autoresolve",
"lionweb.generation",
"lionweb.language",
"lionweb.lionweb_version",
"lionweb.model",
"lionweb.self.lioncore",
"lionweb.serialization",
"lionweb.utils",
]


class ImportsTest(unittest.TestCase):
"""Verifies there are no circular imports between the lionweb packages.

Each package is imported first, in a fresh interpreter: an import cycle can
go unnoticed in the rest of the suite, where modules are already loaded in
an order that happens to work.
"""

def test_each_package_can_be_imported_first(self):
env = dict(os.environ)
env["PYTHONPATH"] = os.pathsep.join(filter(None, [SRC_DIR, env.get("PYTHONPATH")]))
for module in MODULES:
with self.subTest(module=module):
result = subprocess.run(
[sys.executable, "-c", f"import {module}"],
env=env,
capture_output=True,
text=True,
)
self.assertEqual(result.returncode, 0, result.stderr)


if __name__ == "__main__":
unittest.main()
Loading