rename: tea-modulo / tea_modulo -> tea (distribution, package, entry-point groups, MLflow names, image paths)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
The boundary rule: a module imports only `tea_modulo.contracts`, the standard
|
||||
The boundary rule: a module imports only `tea.contracts`, the standard
|
||||
library and its approved third-party libraries. It never imports another
|
||||
`tea_modulo` module, so any module can be replaced without touching the rest.
|
||||
`tea` module, so any module can be replaced without touching the rest.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -12,7 +12,7 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
SRC = Path(__file__).resolve().parents[1] / "src" / "tea_modulo"
|
||||
SRC = Path(__file__).resolve().parents[1] / "src" / "tea"
|
||||
|
||||
# Approved third-party libraries (top-level import names).
|
||||
BASE = {"numpy", "scipy", "pandas", "mne", "sklearn", "antropy", "fooof", "yasa",
|
||||
@@ -31,7 +31,7 @@ LEGACY_ADAPTERS = {"_adapter.py", "fhir.py", "api.py", "__init__.py"}
|
||||
|
||||
|
||||
def unit_of(path: Path) -> tuple[str, ...]:
|
||||
"""The replaceable unit a file belongs to, as a path tuple under tea_modulo."""
|
||||
"""The replaceable unit a file belongs to, as a path tuple under tea."""
|
||||
rel = path.relative_to(SRC).parts
|
||||
if rel[0] == "legacy":
|
||||
rest = rel[1:]
|
||||
@@ -82,20 +82,20 @@ FILES = sorted(p for p in SRC.rglob("*.py"))
|
||||
@pytest.mark.parametrize("path", FILES, ids=[str(p.relative_to(SRC)) for p in FILES])
|
||||
def test_imports_respect_boundaries(path):
|
||||
unit = unit_of(path)
|
||||
own = "tea_modulo." + ".".join(unit) if unit else "tea_modulo"
|
||||
own = "tea." + ".".join(unit) if unit else "tea"
|
||||
bad = []
|
||||
for mod, line in imports_of(path):
|
||||
top = mod.split(".")[0]
|
||||
if top == "tea_modulo":
|
||||
if top == "tea":
|
||||
if unit and unit[0] == "export":
|
||||
ok = mod == own or mod.startswith(own + ".")
|
||||
elif not unit:
|
||||
ok = mod in ("tea_modulo", "tea_modulo.contracts") or mod.startswith("tea_modulo.contracts.")
|
||||
ok = mod in ("tea", "tea.contracts") or mod.startswith("tea.contracts.")
|
||||
else:
|
||||
ok = (mod == "tea_modulo.contracts" or mod.startswith("tea_modulo.contracts.")
|
||||
ok = (mod == "tea.contracts" or mod.startswith("tea.contracts.")
|
||||
or mod == own or mod.startswith(own + "."))
|
||||
if unit == ("contracts",):
|
||||
ok = mod.startswith("tea_modulo.contracts")
|
||||
ok = mod.startswith("tea.contracts")
|
||||
elif top in sys.stdlib_module_names or top == "__future__":
|
||||
ok = True
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user