Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdewinter authored Dec 9, 2023
1 parent 6148b96 commit da41320
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pymarkdown/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def __handle_scan_results(
self, return_code: int, this_presentation: "_ApiPresentation"
) -> "PyMarkdownScanPathResult":
assert (
len(this_presentation.pso) == 0
not this_presentation.pso
) # should not display for scan_path, but for ext ops and plugin ops
if return_code != 0:
self.__generate_exception(this_presentation)
Expand Down
2 changes: 1 addition & 1 deletion pymarkdown/container_blocks/container_grab_bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def is_leaf_tokens_empty(self) -> bool:
"""
xxx
"""
return len(self.__leaf_tokens) == 0
return not self.__leaf_tokens

def extend_leaf_tokens(self, tokens_to_append: List[MarkdownToken]) -> None:
"""
Expand Down
5 changes: 1 addition & 4 deletions pymarkdown/container_blocks/container_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ def __reduce_containers_if_required_bq(
parser_state, position_marker, extracted_whitespace, x_tokens
)
was_list_ended = False
if (
len(grab_bag.container_tokens)
and grab_bag.container_tokens[-1].is_end_token
):
if grab_bag.container_tokens and grab_bag.container_tokens[-1].is_end_token:
end_token = cast(EndMarkdownToken, grab_bag.container_tokens[-1])
was_list_ended = end_token.start_markdown_token.is_list_start

Expand Down
2 changes: 1 addition & 1 deletion pymarkdown/extensions/disallowed_raw_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def apply_configuration(
tag_config_name = f"extensions.{self.get_identifier()}.change_tag_names"
for next_tag_part in modify_tag_names.split(","):
next_tag_part = next_tag_part.strip()
if len(next_tag_part) == 0:
if not next_tag_part:
raise ValueError(
f"Configuration item '{tag_config_name}' contains at least one empty string."
)
Expand Down
2 changes: 1 addition & 1 deletion pymarkdown/general/tab_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def parse_thematic_break_with_tab(

split_tab = False
split_tab_with_block_quote_suffix = False
if len(tabified_leading_spaces) > 0:
if tabified_leading_spaces:
assert extracted_whitespace is not None
(
tabified_prefix,
Expand Down
2 changes: 1 addition & 1 deletion pymarkdown/inline/inline_text_block_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def __complete_inline_block_processing(
current_string = InlineHelper.append_text(current_string, text_to_append)
POGGER.debug("current_string>:$:<", current_string)

have_processed_once = len(inline_blocks) != 0 or start_index != 0
have_processed_once = inline_blocks or start_index != 0
if current_string or not have_processed_once:
InlineTextBlockHelper.__complete_inline_block_processing_build_token(
current_string,
Expand Down
6 changes: 1 addition & 5 deletions pymarkdown/leaf_blocks/fenced_leaf_block_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,7 @@ def __handle_fenced_code_block_with_tab_and_extracted_whitespace(

POGGER.debug("new_extracted_whitespace>:$:<", new_extracted_whitespace)
POGGER.debug("extracted_whitespace>:$:<", extracted_whitespace)
replacement_string = (
ParserHelper.replace_noop_character
if len(after_count) == 0
else after_count
)
replacement_string = after_count or ParserHelper.replace_noop_character

new_extracted_whitespace = ParserHelper.create_replacement_markers(
extracted_whitespace, replacement_string
Expand Down
4 changes: 2 additions & 2 deletions pymarkdown/leaf_blocks/leaf_block_processor_paragraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def __calculate_corrected_tab_text_prefix(
last_container_index = parser_state.find_last_container_on_stack()
last_container_token = parser_state.token_stack[last_container_index]
is_block_quote_container = last_container_token.is_block_quote
assert len(corrected_extracted_whitespace) > 0
assert corrected_extracted_whitespace
(
corrected_prefix,
corrected_suffix,
Expand Down Expand Up @@ -364,7 +364,7 @@ def __handle_paragraph_prep_block_reduce(
only_these_blocks=[BlockQuoteStackToken],
include_block_quotes=True,
)
if len(new_tokens) != 0:
if new_tokens:
assert (
extracted_whitespace is not None
and parser_state.token_stack[-1].is_list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def __xx_multiple_fix_leading_spaces(
POGGER.debug(
"block_quote_token.leading_spaces>:$:<", block_quote_token.bleading_spaces
)
is_first = len(block_quote_token.bleading_spaces) == 0
is_first = not block_quote_token.bleading_spaces
for prefix_to_add in leading_spaces:
if split_tabs_list[0]:
prefix_to_add = prefix_to_add[:-1]
Expand Down
2 changes: 1 addition & 1 deletion pymarkdown/plugins/rule_pml_100.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def initialize_from_config(self) -> None:
tag_config_name = "plugins.disallowed-html.change_tag_names"
for next_tag_part in modify_tag_names.split(","):
next_tag_part = next_tag_part.strip()
if len(next_tag_part) == 0:
if not next_tag_part:
raise ValueError(
f"Configuration item '{tag_config_name}' contains at least one empty string."
)
Expand Down
2 changes: 1 addition & 1 deletion pymarkdown/tokens/text_markdown_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def __handle_text_token_normal_enhanced(
current_line += found_prefix

# POGGER.debug("currernt_line>:$:<", current_line)
assert len(current_line)
assert current_line
processed_lines.append(current_line)

arrays_to_combine.append(processed_lines)

0 comments on commit da41320

Please sign in to comment.