From f0ed9d29a796af678ecd9b927a7cdb1b1030bd30 Mon Sep 17 00:00:00 2001 From: Adam Bittlingmayer Date: Mon, 22 Jan 2024 13:13:56 +0400 Subject: [PATCH] Update test_enforce_style.py --- .github/tests/test_enforce_style.py | 30 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/tests/test_enforce_style.py b/.github/tests/test_enforce_style.py index 128174c7..3c1585b1 100644 --- a/.github/tests/test_enforce_style.py +++ b/.github/tests/test_enforce_style.py @@ -55,22 +55,20 @@ def check_spellings(file_path): # Extract only the letters raw_word = re.sub(r'^[^a-zA-Z\'-]*|[^a-zA-Z\'-]*$', '', word) - if raw_word: - - # Skip CamelCase and all-uppercase words - if is_camel_case(raw_word) or raw_word.isupper(): - continue - - # If a US word but not a UK word - if us.check(raw_word) and not uk.check(raw_word) - - # Check if the word is a proper noun in context - # This is a relatively expensive check. - assert is_proper_noun_in_context(_line, raw_word), f'''US-specific spelling: - "{ raw_word }" in { file_path } - line: { line } - suggestions: { uk.suggest(raw_word) } - ''' + # Skip non-alpha, ALLCAPS and camelCase/CamelCase + if not raw_word or raw_word.isupper() or is_camel_case(raw_word): + continue + + # If a US word but not a UK word + if us.check(raw_word) and not uk.check(raw_word): + + # Check if the word is a proper noun in context + # This is a relatively expensive check. + assert is_proper_noun_in_context(_line, raw_word), f'''US-specific spelling: + "{ raw_word }" in { file_path } + line: { line } + suggestions: { uk.suggest(raw_word) } + ''' EXCLUDE_DIRS = ['vendor'] EXCLUDE_FILES = ['README.md', 'CHANGELOG.md']