diff options
| author | 2020-08-25 11:18:34 -0700 | |
|---|---|---|
| committer | 2020-08-25 11:20:35 -0700 | |
| commit | a955b61aa7e4692a99034357c7b56d488327a2a4 (patch) | |
| tree | 7a9bed6f5203aecce46cb26acd9cba3a1a43ec13 | |
| parent | Stats: use the is_in_category util function (diff) | |
Code block: make _get_leading_spaces more readable
A for loop is less confusing according to reviews.
| -rw-r--r-- | bot/cogs/codeblock/parsing.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/bot/cogs/codeblock/parsing.py b/bot/cogs/codeblock/parsing.py index ea007b6f1..01c220c61 100644 --- a/bot/cogs/codeblock/parsing.py +++ b/bot/cogs/codeblock/parsing.py @@ -179,14 +179,12 @@ def parse_bad_language(content: str) -> Optional[BadLanguage]: def _get_leading_spaces(content: str) -> int: """Return the number of spaces at the start of the first line in `content`.""" - current = content[0] leading_spaces = 0 - - while current == " ": - leading_spaces += 1 - current = content[leading_spaces] - - return leading_spaces + for char in content: + if char == " ": + leading_spaces += 1 + else: + return leading_spaces def _fix_indentation(content: str) -> str: |