From 7dccfd233cc0f5ca4eef0fe017c0bbac7ca6906b Mon Sep 17 00:00:00 2001 From: Matthew Rowles Date: Thu, 18 Jun 2026 19:43:57 +0800 Subject: [PATCH 1/3] add has_warnings --- src/cifflow/dictionary/ddlm_parser.py | 11 +++++++++++ tasks/todo.md | 10 +++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cifflow/dictionary/ddlm_parser.py b/src/cifflow/dictionary/ddlm_parser.py index fc4124c..aa6ebfc 100644 --- a/src/cifflow/dictionary/ddlm_parser.py +++ b/src/cifflow/dictionary/ddlm_parser.py @@ -46,6 +46,10 @@ class DdlmDictionary: uri: Value of ``_dictionary.uri`` from the top-level dictionary source, or ``None`` if absent. + has_warnings: + ``True`` if any non-fatal issues were recorded during loading. + Warnings range from purely informational to significant; inspect + :attr:`warnings` directly to determine severity. """ name: str @@ -59,3 +63,10 @@ class DdlmDictionary: warnings: list[str] = field(default_factory=list) source_files: list[str] = field(default_factory=list) uri: str | None = None + + @property + def has_warnings(self) -> bool: + return bool(self.warnings) + + # def __bool__(self) -> bool: + # return self.is_valid diff --git a/tasks/todo.md b/tasks/todo.md index 0c644e7..b5e7cbf 100644 --- a/tasks/todo.md +++ b/tasks/todo.md @@ -49,9 +49,13 @@ Decomposed all F-grade and all 6 reducible E-grade functions into private helper ingest a real `.cif` to file-backed SQLite, emit to `.cif` and re-ingest, property-based tests for `_BlockData` helpers. - 4. **Unify severity levels** across parser/ingest/validation — audit every `on_error` / - `ParseError` site; assign `'Error' | 'Warning' | 'Info'`; standardise message phrasing; - decide `ingest()` return type. + 4. **Unify severity levels** across parser/ingest/validation/dictionary — audit every `on_error` / + `ParseError` site and every `warn()` call in `loader.py`; assign `'Error' | 'Warning' | 'Info'`; + standardise message phrasing; decide `ingest()` return type. Dictionary warnings currently span + the full range from purely informational ("has 2 data blocks — using first") to effectively fatal + ("contains no data blocks"), making `DdlmDictionary.is_valid` / `__bool__` meaningless as a + single threshold. Fix requires classifying each warning site before exposing validity on the + public API. 6. **`CifBuilder` cross-type duplicate tag detection** — scalar-then-loop silently loses scalar; loop-then-scalar makes loop structurally inconsistent. Fix in `builder.py` with From 55c4c295d2a3fdd630b185e513ba00d1993c8255 Mon Sep 17 00:00:00 2001 From: Matthew Rowles Date: Thu, 18 Jun 2026 19:48:03 +0800 Subject: [PATCH 2/3] fix docstring --- src/cifflow/dictionary/ddlm_parser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cifflow/dictionary/ddlm_parser.py b/src/cifflow/dictionary/ddlm_parser.py index aa6ebfc..edd91bd 100644 --- a/src/cifflow/dictionary/ddlm_parser.py +++ b/src/cifflow/dictionary/ddlm_parser.py @@ -66,6 +66,13 @@ class DdlmDictionary: @property def has_warnings(self) -> bool: + """Return True if any non-fatal issues were recorded during loading. + + Warnings range from purely informational (e.g. a dictionary with + multiple data blocks) to significant (e.g. a skipped import). A + dictionary with warnings is not necessarily unusable; inspect + :attr:`warnings` to determine severity. + """ return bool(self.warnings) # def __bool__(self) -> bool: From 85f69cf63d333a608d3b5f3d09b1ddf8732ef5bf Mon Sep 17 00:00:00 2001 From: Matthew Rowles Date: Thu, 18 Jun 2026 19:57:25 +0800 Subject: [PATCH 3/3] Update ddlm_parser.py --- src/cifflow/dictionary/ddlm_parser.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cifflow/dictionary/ddlm_parser.py b/src/cifflow/dictionary/ddlm_parser.py index edd91bd..15f32ba 100644 --- a/src/cifflow/dictionary/ddlm_parser.py +++ b/src/cifflow/dictionary/ddlm_parser.py @@ -46,10 +46,6 @@ class DdlmDictionary: uri: Value of ``_dictionary.uri`` from the top-level dictionary source, or ``None`` if absent. - has_warnings: - ``True`` if any non-fatal issues were recorded during loading. - Warnings range from purely informational to significant; inspect - :attr:`warnings` directly to determine severity. """ name: str