aboutsummaryrefslogtreecommitdiff
path: root/pw_presubmit/py/pw_presubmit/inclusive_language.py
diff options
context:
space:
mode:
Diffstat (limited to 'pw_presubmit/py/pw_presubmit/inclusive_language.py')
-rw-r--r--pw_presubmit/py/pw_presubmit/inclusive_language.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/pw_presubmit/py/pw_presubmit/inclusive_language.py b/pw_presubmit/py/pw_presubmit/inclusive_language.py
index 8ef0a9c00..34fde80f2 100644
--- a/pw_presubmit/py/pw_presubmit/inclusive_language.py
+++ b/pw_presubmit/py/pw_presubmit/inclusive_language.py
@@ -18,7 +18,7 @@ from pathlib import Path
import re
from typing import Dict, List, Union
-from . import presubmit
+from . import presubmit, presubmit_context
# List borrowed from Android:
# https://source.android.com/setup/contribute/respectful-code
@@ -107,13 +107,20 @@ class LineMatch:
@presubmit.check(name='inclusive_language')
def presubmit_check(
- ctx: presubmit.PresubmitContext,
+ ctx: presubmit_context.PresubmitContext,
words_regex=NON_INCLUSIVE_WORDS_REGEX,
):
"""Presubmit check that ensures files do not contain banned words."""
+ # No subprocesses are run for inclusive_language so don't perform this check
+ # if dry_run is on.
+ if ctx.dry_run:
+ return
+
found_words: Dict[Path, List[Union[PathMatch, LineMatch]]] = {}
+ ctx.paths = presubmit_context.apply_exclusions(ctx)
+
for path in ctx.paths:
match = words_regex.search(str(path.relative_to(ctx.root)))
if match:
@@ -174,7 +181,7 @@ ignored with "inclusive-language: disable" and reenabled with
)
# Re-enable just in case: inclusive-language: enable.
- raise presubmit.PresubmitFailure
+ raise presubmit_context.PresubmitFailure
def inclusive_language_checker(*words):
@@ -183,7 +190,7 @@ def inclusive_language_checker(*words):
regex = _process_inclusive_language(*words)
def inclusive_language( # pylint: disable=redefined-outer-name
- ctx: presubmit.PresubmitContext,
+ ctx: presubmit_context.PresubmitContext,
):
globals()['inclusive_language'](ctx, regex)