@@ -436,27 +436,30 @@ def found_include_markdown_tag( # noqa: PLR0912, PLR0915
436436 offset_match = ARGUMENT_REGEXES ['heading-offset' ]().search (
437437 arguments_string ,
438438 )
439- if offset_match :
440- offset_raw_value = offset_match [1 ]
441- if offset_raw_value == '' :
442- location = process .file_lineno_message (
443- page_src_path , docs_dir , directive_lineno (),
444- )
445- raise PluginError (
446- "Invalid empty 'heading-offset' argument in"
447- f" 'include-markdown' directive at { location } " ,
448- )
449- try :
450- offset = int (offset_raw_value )
451- except ValueError :
452- location = process .file_lineno_message (
453- page_src_path , docs_dir , directive_lineno (),
454- )
455- raise PluginError (
456- f"Invalid 'heading-offset' argument"
457- f" '{ offset_raw_value } ' in 'include-markdown'"
458- f" directive at { location } " ,
459- ) from None
439+ try :
440+ # Here None[1] would raise a TypeError
441+ offset_raw_value = offset_match [1 ] # type: ignore
442+ except (IndexError , TypeError ): # pragma: no cover
443+ offset_raw_value = ''
444+ if offset_raw_value == '' :
445+ location = process .file_lineno_message (
446+ page_src_path , docs_dir , directive_lineno (),
447+ )
448+ raise PluginError (
449+ "Invalid empty 'heading-offset' argument in"
450+ f" 'include-markdown' directive at { location } " ,
451+ )
452+ try :
453+ offset = int (offset_raw_value )
454+ except ValueError :
455+ location = process .file_lineno_message (
456+ page_src_path , docs_dir , directive_lineno (),
457+ )
458+ raise PluginError (
459+ f"Invalid 'heading-offset' argument"
460+ f" '{ offset_raw_value } ' in 'include-markdown'"
461+ f" directive at { location } " ,
462+ ) from None
460463
461464 bool_options , invalid_bool_args = parse_bool_options (
462465 [
0 commit comments