mirror of
https://github.com/esphome/esphome.git
synced 2025-07-02 21:23:16 +01:00
Use inclusive terminology (#1137)
This commit is contained in:
esphome
components
core
script
@ -91,7 +91,8 @@ def lint_post_check(func):
|
||||
|
||||
|
||||
def lint_re_check(regex, **kwargs):
|
||||
prog = re.compile(regex, re.MULTILINE)
|
||||
flags = kwargs.pop('flags', re.MULTILINE)
|
||||
prog = re.compile(regex, flags)
|
||||
decor = lint_content_check(**kwargs)
|
||||
|
||||
def decorator(func):
|
||||
@ -327,6 +328,24 @@ def lint_pragma_once(fname, content):
|
||||
return None
|
||||
|
||||
|
||||
@lint_re_check(r'(whitelist|blacklist|slave)', exclude=['script/ci-custom.py'],
|
||||
flags=re.IGNORECASE | re.MULTILINE)
|
||||
def lint_inclusive_language(fname, match):
|
||||
# From https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=49decddd39e5f6132ccd7d9fdc3d7c470b0061bb
|
||||
return ("Avoid the use of whitelist/blacklist/slave.\n"
|
||||
"Recommended replacements for 'master / slave' are:\n"
|
||||
" '{primary,main} / {secondary,replica,subordinate}\n"
|
||||
" '{initiator,requester} / {target,responder}'\n"
|
||||
" '{controller,host} / {device,worker,proxy}'\n"
|
||||
" 'leader / follower'\n"
|
||||
" 'director / performer'\n"
|
||||
"\n"
|
||||
"Recommended replacements for 'blacklist/whitelist' are:\n"
|
||||
" 'denylist / allowlist'\n"
|
||||
" 'blocklist / passlist'")
|
||||
|
||||
|
||||
|
||||
@lint_content_find_check('ESP_LOG', include=['*.h', '*.tcc'], exclude=[
|
||||
'esphome/components/binary_sensor/binary_sensor.h',
|
||||
'esphome/components/cover/cover.h',
|
||||
@ -365,7 +384,7 @@ def add_errors(fname, errs):
|
||||
lineno = 1
|
||||
col = 1
|
||||
msg = err
|
||||
if not isinstance(err, str):
|
||||
if not isinstance(msg, str):
|
||||
raise ValueError("Error is not instance of string!")
|
||||
if not isinstance(lineno, int):
|
||||
raise ValueError("Line number is not an int!")
|
||||
|
Reference in New Issue
Block a user