Skip to content

Commit

Permalink
Update test_enforce_style.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bittlingmayer authored Jan 22, 2024
1 parent f021598 commit f0ed9d2
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions .github/tests/test_enforce_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit f0ed9d2

Please sign in to comment.