@@ -89,9 +89,9 @@ def found_include_tag(match: re.Match[str]) -> str:
8989
9090 exclude_match = ARGUMENT_REGEXES ['exclude' ].search (arguments_string )
9191 if exclude_match is None :
92- if defaults ['exclude' ] is None :
92+ if defaults ['exclude' ] is None : # pragma: no branch
9393 ignore_paths : list [str ] = []
94- else :
94+ else : # pragma: no cover
9595 ignore_paths = glob .glob (defaults ['exclude' ])
9696 else :
9797 exclude_string = parse_string_argument (exclude_match )
@@ -121,7 +121,7 @@ def found_include_tag(match: re.Match[str]) -> str:
121121 else :
122122 file_paths_to_include = process .filter_paths (
123123 glob .iglob (file_path_glob , recursive = True ),
124- ignore_paths = ignore_paths ,
124+ ignore_paths ,
125125 )
126126
127127 if not file_paths_to_include :
@@ -209,7 +209,7 @@ def found_include_tag(match: re.Match[str]) -> str:
209209 else :
210210 new_text_to_include = process .read_file (file_path , encoding )
211211
212- if start is not None or end is not None :
212+ if start or end :
213213 new_text_to_include , * expected_not_found = (
214214 process .filter_inclusions (
215215 start ,
@@ -307,9 +307,9 @@ def found_include_markdown_tag(match: re.Match[str]) -> str:
307307
308308 exclude_match = ARGUMENT_REGEXES ['exclude' ].search (arguments_string )
309309 if exclude_match is None :
310- if defaults ['exclude' ] is None :
310+ if defaults ['exclude' ] is None : # pragma: no branch
311311 ignore_paths : list [str ] = []
312- else :
312+ else : # pragma: no cover
313313 ignore_paths = glob .glob (defaults ['exclude' ])
314314 else :
315315 exclude_string = parse_string_argument (exclude_match )
@@ -340,7 +340,7 @@ def found_include_markdown_tag(match: re.Match[str]) -> str:
340340 else :
341341 file_paths_to_include = process .filter_paths (
342342 glob .iglob (file_path_glob , recursive = True ),
343- ignore_paths = ignore_paths ,
343+ ignore_paths ,
344344 )
345345
346346 if not file_paths_to_include :
@@ -432,16 +432,27 @@ def found_include_markdown_tag(match: re.Match[str]) -> str:
432432 arguments_string ,
433433 )
434434 if offset_match :
435+ offset = offset_match .group (1 )
436+ if offset == '' :
437+ lineno = lineno_from_content_start (
438+ markdown ,
439+ directive_match_start ,
440+ )
441+ raise BuildError (
442+ "Invalid empty 'heading-offset' argument in"
443+ " 'include-markdown' directive at"
444+ f' { os .path .relpath (page_src_path , docs_dir )} :{ lineno } ' ,
445+ )
435446 try :
436- offset = int (offset_match . group ( 1 ) )
447+ offset = int (offset )
437448 except ValueError :
438449 lineno = lineno_from_content_start (
439450 markdown ,
440451 directive_match_start ,
441452 )
442453 raise BuildError (
443- "Invalid 'heading-offset' argument in 'include-markdown' "
444- ' directive at '
454+ f "Invalid 'heading-offset' argument \" { offset } \" in "
455+ " 'include-markdown' directive at "
445456 f'{ os .path .relpath (page_src_path , docs_dir )} :{ lineno } ' ,
446457 )
447458 else :
@@ -468,7 +479,7 @@ def found_include_markdown_tag(match: re.Match[str]) -> str:
468479 else :
469480 new_text_to_include = process .read_file (file_path , encoding )
470481
471- if start is not None or end is not None :
482+ if start or end :
472483 new_text_to_include , * expected_not_found = (
473484 process .filter_inclusions (
474485 start ,
0 commit comments