terrencepreilly / darglint

A python documentation linter which checks that the docstring description matches the definition.
MIT License
481 stars 41 forks source link

Add flag to flake8 to specify ignore regex #176

Closed AdamGleave closed 2 years ago

AdamGleave commented 2 years ago

When darglint is installed, it is run by flake8 automatically. This is a good default, but sometimes is undesirable. This PR adds a flag --darglint-disable to flake8 to disable darglint on a case-by-case basis.

In my case, running flake8 on my entire source tree takes 4 minutes when darglint is installed, v.s. 4 seconds without. So I want to disable darglint when running flake8 as a commit hook (where quick response is important), but still run darglint when running on continuous integration (where it's still faster than our unit test suite).

terrencepreilly commented 2 years ago

I'm so sorry that I took so long to review this. I'm kind of surprised that flake8 doesn't have an option to disable an extension. (Since it does have an option to enable an extension.) Naively, I'd have expected flake8 to have requested extensions to register under a given error code prefix.

Anyway, I'd prefer to avoid adding new configuration options, if there is one which can be reused. Darglint currently has an option, --ignore-regex. I don't know if this is a common option, though, so maybe it would be better to prefix it with "darglint", like --darglint-ignore-regex. In any case, this would allow us a lot more flexibility in restricting checks. So, for your use case, the following would work:

flake8 --ignore-regex='.*' <dir>

This would run darglint, but it would short-circuit pretty quickly. (At least as quickly as your change.)

Would you like to update your PR, or would you like me to just make the change? Anyway, thanks for the suggestion -- it seems like a good addition!

AdamGleave commented 2 years ago

Thanks for the suggestion, I agree this is a more elegant and flexible solution, I've updated the PR accordingly.

terrencepreilly commented 2 years ago

Looks good, thanks for the PR! I'll try to deploy it this weekend.

terrencepreilly commented 2 years ago

Sorry, took another week, but it should now be available in v1.8.1

AdamGleave commented 2 years ago

Thanks!