From 48d8651a481aac7e909a948921e49da07b5dbdea Mon Sep 17 00:00:00 2001 From: Ana Date: Thu, 17 Sep 2026 10:31:26 +0200 Subject: [PATCH 1/2] fix: allow requires modules without a local definitions section Merging exported concepts dereferenced the definitions slot, which is None when the section is absent. Create an empty container first. --- plain_file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plain_file.py b/plain_file.py index ca856e40..2fcf2b82 100644 --- a/plain_file.py +++ b/plain_file.py @@ -737,6 +737,9 @@ def process_exported_definitions(plain_source: dict, exported_definitions: list[ if len(exported_definitions) == 0: return + if plain_source[plain_spec.DEFINITIONS] is None: + plain_source[plain_spec.DEFINITIONS] = mistletoe.Document("") + with PlainRenderer() as renderer: for exported_definition in exported_definitions: add_defintion = True From d934bd7aec96cf3944b2cff627a92b638c7a0428 Mon Sep 17 00:00:00 2001 From: Ana Date: Thu, 17 Sep 2026 17:50:53 +0200 Subject: [PATCH 2/2] test: add regression test for requires without local definitions --- .../requires_without_definitions_example.plain | 10 ++++++++++ tests/test_plainfileparser.py | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/data/plainfileparser/requires_without_definitions_example.plain diff --git a/tests/data/plainfileparser/requires_without_definitions_example.plain b/tests/data/plainfileparser/requires_without_definitions_example.plain new file mode 100644 index 00000000..c63b375c --- /dev/null +++ b/tests/data/plainfileparser/requires_without_definitions_example.plain @@ -0,0 +1,10 @@ +--- +requires: + - exported_concepts +--- + +***implementation reqs*** +- The :Concept: concept must be reused. + +***functional specs*** +- Implement a second wrapper for the :Concept: concept. diff --git a/tests/test_plainfileparser.py b/tests/test_plainfileparser.py index 403e85de..83422f9c 100644 --- a/tests/test_plainfileparser.py +++ b/tests/test_plainfileparser.py @@ -685,6 +685,14 @@ def test_exported_concepts(get_test_data_path): ) +def test_requires_without_definitions(get_test_data_path): + _, plain_source, _ = plain_file.plain_file_parser( + "requires_without_definitions_example.plain", + [get_test_data_path("data/plainfileparser")], + ) + assert plain_source[plain_spec.DEFINITIONS] == [{"markdown": "- :Concept: is a concept."}] + + def test_topological_sort(get_test_data_path): _, plain_source, _ = plain_file.plain_file_parser( "topological_sort.plain", [get_test_data_path("data/plainfileparser")]