Item 4: remove guarded seams and dead code between the merged pieces. done 4 / next 5 (grouped help)

This commit is contained in:
swaits committed 2026-11-23 12:26:42 -07:00
1 parent ed018a364c
commit 6787ef0ae9
23 files changed
+82 -261

No files matched your search

+18 -1
View File
@@ -983,7 +983,7 @@ class Store(Base):
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
bad = []
for n in sorted(os.listdir(os.path.join(root, "sisi"))):
if not n.endswith(".py") or n == "gate.py": # gate.py's retro.lessons_block is the live gate seam
if not n.endswith(".py"):
continue
with open(os.path.join(root, "sisi", n)) as f:
for i, line in enumerate(f, 1):
@@ -992,6 +992,23 @@ class Store(Base):
bad.append("%s:%d" % (n, i))
self.assertEqual(bad, [])
def test_no_guarded_seams_between_modules_that_always_exist(self):
"""Item 4: no `except ImportError` or `hasattr(module, ...)` probe stands in for a module of this
package, and nothing names a removed seam. The one platform probe (fcntl, absent on Windows, in pdata) stays."""
import re
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
bad = []
for n in sorted(os.listdir(os.path.join(root, "sisi"))):
if not n.endswith(".py"):
continue
with open(os.path.join(root, "sisi", n)) as f:
for i, line in enumerate(f, 1):
if n != "pdata.py" and re.search(r"except \(?ImportError|hasattr\((delivery|unit|gate|retro|learning|cycle)\b", line):
bad.append("%s:%d" % (n, i))
if re.search(r"retro\.(TEMPLATE|satisfied|lessons_block)|ensure_imported", line):
bad.append("%s:%d" % (n, i))
self.assertEqual(bad, [])
def test_no_resource_warnings_from_the_learning_commands(self):
"""Item 13: file handles are closed; every learning command runs clean under -W always."""
_contract(self)