Skip to content

Commit 886698e

Browse files
committed
Force line number in error messages
1 parent 76126c8 commit 886698e

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/sphinx_notion/__init__.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,19 +370,12 @@ def _create_styled_text_from_node(*, child: nodes.Element) -> Text:
370370
]
371371

372372
if unsupported_styles:
373-
if child.line is not None and child.source is not None:
374-
unsupported_style_msg = (
375-
"Unsupported text style classes: "
376-
f"{', '.join(unsupported_styles)}. "
377-
f"Text on line {child.line} in {child.source} will be "
378-
"rendered without styling."
379-
)
380-
else:
381-
unsupported_style_msg = (
382-
"Unsupported text style classes: "
383-
f"{', '.join(unsupported_styles)}. "
384-
"Text will be rendered without styling."
385-
)
373+
unsupported_style_msg = (
374+
"Unsupported text style classes: "
375+
f"{', '.join(unsupported_styles)}. "
376+
f"Text on line {child.parent.line} in {child.parent.source} will "
377+
"be rendered without styling."
378+
)
386379
_LOGGER.warning(unsupported_style_msg)
387380

388381
color: BGColor | Color | None = bg_color or text_color

tests/test_integration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2330,7 +2330,8 @@ def test_text_styles_unsupported_color(
23302330

23312331
expected_warning = (
23322332
"Unsupported text style classes: text-cyan. "
2333-
"Text will be rendered without styling."
2333+
f"Text on line 1 in {tmp_path / 'src' / 'index.rst'} will be rendered "
2334+
"without styling."
23342335
)
23352336

23362337
normal_text = text(text="This is ")

0 commit comments

Comments
 (0)