Skip to content

Add a "require plugin" option #283

@asottile

Description

@asottile

In GitLab by @mschwager on Jan 7, 2019, 07:34

Hi all,

I'd like to request an additional option to flake8 for requiring certain plugin(s) are installed and selected during a run. For example,

$ flake8 --require=XYZ --select=XYZ /path/to/lint

I could also envision the new option implies a --select. Naming like --require-plugins also makes sense to me.

This would be very helpful for reminding developers to have a set list of flake8 plugins installed on their machine. For example, a common use case may be that a repository uses a Makefile for various common operations including linting:

lint:
    flake8 --select=XYZ /path/to/lint

.PHONY: lint

Both the CI/CD system and developers use the Makefile to run these common operations, i.e. make lint. However, if the CI/CD system has the required plugins, but the developer's machine does not, then the local dev machine will silently ignore the selected rules:

$ flake8 --select=DOESNTEXIST /path/to/lint
$ echo $?
0

I'm envisioning a flag that would loudly complain if a required plugin is not installed:

lint:
    flake8 --require=ABC,XYZ /path/to/lint

.PHONY: lint

Keying off the plugin's prefix, similar to --select and --ignore, seems to be the most consistent solution in my opinion.

Another option could be for flake8 to complain loudly if a plugin in a --select flag doesn't exist. However, a new flag makes more sense to me for ensuring backwards compatibility and because this seems like a net-new feature.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions