tenseleyflow/documentlanguagemodel / f91b74e

Browse files

export/sway_json: pair [unused-ignore] with [import-not-found] so mypy passes both with-extra and without-extra installs

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
f91b74ebd9811543d5a6fd15e8377a36653e98c7
Parents
bdc969f
Tree
ed3eb4f

1 changed file

StatusFile+-
M src/dlm/export/sway_json.py 8 5
src/dlm/export/sway_json.pymodified
@@ -89,13 +89,16 @@ def write_sway_json(dlm_path: Path, export_dir: Path) -> Path:
8989
     try:
9090
         # Both imports are required: ``resolve_dlm`` parses the .dlm
9191
         # into the DlmHandle that ``build_spec_dict`` consumes.
92
-        # ``# type: ignore[import-not-found]`` because dlm-sway is in
93
-        # the optional ``[sway]`` extra; mypy strict shouldn't fail
94
-        # type-checking on a deliberately-optional import.
95
-        from dlm_sway.integrations.dlm.autogen import (  # type: ignore[import-not-found]
92
+        # The combined ``[import-not-found,unused-ignore]`` keeps mypy
93
+        # happy across two install postures: when dlm-sway is missing
94
+        # (``import-not-found`` fires), and when CI installs the
95
+        # ``[sway]`` extra (the import succeeds — without the
96
+        # ``unused-ignore`` paired code, mypy then complains that the
97
+        # ``import-not-found`` ignore is itself unused).
98
+        from dlm_sway.integrations.dlm.autogen import (  # type: ignore[import-not-found,unused-ignore]
9699
             build_spec_dict,
97100
         )
98
-        from dlm_sway.integrations.dlm.resolver import (  # type: ignore[import-not-found]
101
+        from dlm_sway.integrations.dlm.resolver import (  # type: ignore[import-not-found,unused-ignore]
99102
             resolve_dlm,
100103
         )
101104
     except ImportError as exc:  # pragma: no cover — env-dep branch