Fixit icon indicating copy to clipboard operation
Fixit copied to clipboard

Inheritable Configurations, Second Attempt

Open dkgi opened this issue 3 years ago • 0 comments

Summary

A lot of this is copy pasting @lisroach's PR #198. Same motivation and 99% same implementation.

We'd like configurations in subdirectories to be able to inherit from configurations in parent directories. We do this by setting inherit: True (defaults to False; probably discussion we should be having because I could see this lead to surprises). Got rid of some global state but currently have only implemented this for run_rules. Other commands might benefit from similar changes (but we'd have to have a discussion about what we can delete; there's a lot of code here that seems superfluous).

Implementation: the meat of this is making get_lint_config take a path as an argument. This defaults to cwd if none is given to be backwards compatible but realistically this shouldn't be an optional parameter. Also changed get_config_rules to get_rules_for_path and similarly added a path parameter. Rest of the change is adjusting to this (directly using in run_rules as well as fixing tests).

Limitations: we're only using this to compute which rules to run at the moment. E.g. my understanding is that override options like noqa etc. Will be mostly ignored. Would prefer to do this as follow-ups to keep change size manageable.

Test Plan

tox -e py38

dkgi avatar Feb 11 '22 16:02 dkgi