Skip to content

Commit e438f19

Browse files
Add requires hint and consistent quoting to functionality errors
1 parent fc001e5 commit e438f19

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

plain_file.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ def process_imports(
403403

404404
if has_functional_specs_section(plain_file_parse_result.plain_source):
405405
raise ImportedModuleWithFunctionalitiesError(
406-
f"Module {module_name} is imported but contains functional specs. "
407-
f"Imported modules may only provide definitions, implementation reqs, and test reqs."
406+
f"Module '{module_name}' is imported but contains functional specs. "
407+
f"Imported modules may only provide definitions, implementation reqs, and test reqs — "
408+
f"use 'requires' instead of 'import' if this module's functionalities should be built on."
408409
)
409410

410411
for specification_heading in plain_file_parse_result.plain_source:
@@ -748,7 +749,7 @@ def plain_file_parser( # noqa: C901
748749
if not has_functional_specs_section(plain_file_parse_result.plain_source):
749750
# No ***functional specs*** section at all: valid as an import, but not renderable. Usage error.
750751
raise MissingFunctionalitiesError(
751-
f"Module {module_name} does not have any functionality specified. "
752+
f"Module '{module_name}' does not have any functionality specified. "
752753
f"At least one functionality is required for rendering."
753754
)
754755

tests/test_imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_imported_module_with_functionalities(load_test_data, get_test_data_path
99
template_dirs = [get_test_data_path("data/imports")]
1010
with pytest.raises(
1111
ImportedModuleWithFunctionalitiesError,
12-
match="is imported but contains functional specs",
12+
match="use 'requires' instead of 'import'",
1313
):
1414
plain_file.parse_plain_source(plain_source_text, {}, template_dirs, [], [])
1515

0 commit comments

Comments
 (0)