Skip to content

Commit

Permalink
Allow individual checks to be disabled by user, per amperser#1091
Browse files Browse the repository at this point in the history
Creates list of individual subchecks which have been disabled by user in config
file and then removes them from the list of checks to be executed. Each
subcheck's function should start with 'check_'. The name of the check should
also match the function. For example: The subcheck
typography.symbols.curly_quotes would be the function check_curly_quotes in
typography.symbols. I saw that some subchecks have slightly different function
names and so these would need to be adjusted. An example is the subcheck
typography.symbols.copyright, which is the function check_copyright_symbol in
typography.symbols. To keep the tests running, I think this subcheck's name
should be adjusted to typography.symbols.copyright_symbol.
  • Loading branch information
samcan committed Sep 6, 2020
1 parent cb619ee commit ba9583f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion proselint/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,20 @@ def get_checks(options):
"""Extract the checks."""
sys.path.append(proselint_path)
checks = []

check_names = [key for (key, val)
in list(options["checks"].items()) if val]
remove_subcheck_names = [key for (key, val)
in list(options["checks"].items()) if not val and
key.count('.') == 2]

for check_name in check_names:
module = importlib.import_module("checks." + check_name)
for d in dir(module):
if re.match("check", d):
checks.append(getattr(module, d))
subcheck_name = check_name + "." + d.replace("check_", "")
if subcheck_name not in remove_subcheck_names:
checks.append(getattr(module, d))

return checks

Expand Down

0 comments on commit ba9583f

Please sign in to comment.