Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional flake8 plugins we'd like to use #1765

Open
3 of 9 tasks
dgw opened this issue Nov 25, 2019 · 13 comments
Open
3 of 9 tasks

Additional flake8 plugins we'd like to use #1765

dgw opened this issue Nov 25, 2019 · 13 comments
Assignees
Labels
Long-term Planning Things that need to happen at some point in the future, but need to NOT happen soon. Low Priority Tests Tracking Tweak

Comments

@dgw
Copy link
Member

dgw commented Nov 25, 2019

I have a list of flake8 plugins I'd like to add after we release 7.0:

  • flake8-future-import for easier enforcement of the required __future__ imports [Unignore more style checks #1561]
  • flake8-import-order to check import sorting (kind of redundant with the existing isort project in isort: add isort to the QA tools #1752, but has the benefit of being integrated with our current checks; in-progress by me, @dgw, in a personal branch named flake8-import-order done by @half-duplex in Add flake8-import-order #1864)
  • flake8-unused-arguments to do what it says on the tin (we can always ignore specific instances for e.g. backward compatibility with # noqa: U100 comments)
  • flake8-comprehensions for sanity checks—these were some of the DeepSource warnings that I thought were actually worth looking at from [POC] all: fix deepsource checks #2016
  • [ ] flake8-quotes to push us toward using single-quotes except when the string contains them (my own preference) (quality: add flake8-quotes #2322) Removed/NAK as the plugin can't be configured to enforce the desired style choices.
  • flake8-requirements for core and plugins (as we extract stuff into separate packages), to make sure dependencies stay sane
  • flake8-string-format to check .format() calls—though it mightn't be maintained any more? and/or there could be places where we intentionally break the conventions for stuff like pluralizing messages
  • flake8-type-checking to guard against runtime overhead from importing modules that only appear in type annotations (implement flake8-type-checking #2300)
  • flake8-docstrings to enforce blank lines (or not) around docstrings, and flag things that aren't documented but should be
  • flake8-rst-docstrings to lint reStructuredText docstrings, keeping our docs more consistent

There are probably more plugins that would be useful, which anyone may suggest here. I'll modify this checklist as needed.

@dgw dgw added this to the 7.1.0 milestone Nov 25, 2019
@dgw dgw self-assigned this Sep 24, 2020
@Exirel
Copy link
Contributor

Exirel commented Oct 30, 2020

I tend to completely ignore the "unused argument" warning in my code: sometimes, you need that argument in your interface, but not every implementation will need it, or even maybe most of them won't. It's OK, it's part of the life of an interface and its implementations.

I think there are better way to improve the code quality than checking that, and adding # noqa: U100 all over the place is not really my cup of tea.

My suggestion: we are all done for 7.1 as far as I'm concerned.

@dgw
Copy link
Member Author

dgw commented Oct 30, 2020

I still have a WIP branch for flake8-docstrings, and I don't intend to ship 7.1 without finishing it.

Unused args, fine, that decision can wait until after 7.1 and we check how many # noqas we'd need.

@half-duplex
Copy link
Member

aaaaaaaaaaaaa
You should comment on issues with draft stuff you've worked on, cause I just spent most of the evening on it again.
Though yours looks like a challenging rebase anyway by now

@dgw
Copy link
Member Author

dgw commented Oct 31, 2020

I did self-assign this issue… But if you're considerably further along than mine (and I'm sure you are), don't worry about it. Especially now that I know someone else is working on it, I'm not gonna go finish mine and open a PR to snipe you.

@Exirel
Copy link
Contributor

Exirel commented Oct 31, 2020

I'm looking at your branch @half-duplex and I really don't like this syntax:

"""
Synopsis of multi-line docstring.

Long description.
"""

I don't see the need for that change.

Also, I don't see the point of adding short docstring just for the sake of having a docstring.

@Exirel
Copy link
Contributor

Exirel commented Oct 31, 2020

Also, if you want to flag stuffs without docstring: use pylint.

@half-duplex
Copy link
Member

I'm looking at your branch @half-duplex and I really don't like this syntax

I wasn't going to break """Synopsis lines, but dgw's branch added that warning.

Also, I don't see the point of adding short docstring just for the sake of having a docstring.

Options: Disable missing docstring warning (ehh). noqa them (ehh). Or add a short, dubiously-useful docstring that can be filled out as needed (eh).

pydocstyle also doesn't seem to find superclass stub method docstrings, so I'm not sure how to deal with that. Right now I'm adding noqas as PyCQA/pydocstyle#309 mentions, since duplicating docstrings, breaking docs and introspection with """Override method.""", or adding a dependency and ignoring all checks for @override methods all seem worse.

@dgw
Copy link
Member Author

dgw commented Oct 31, 2020

I wasn't going to break """Synopsis lines, but dgw's branch added that warning.

It's a WIP, and shouldn't be treated as gospel. I don't like it either, and would have changed it myself before PR'ing.

@Exirel
Copy link
Contributor

Exirel commented Oct 31, 2020

Yeah, it seems to me that what we want for now is just the pylint report.

When improving the code quality, it's often best to do that in 3 steps:

  1. acknowledge the problem with reports that tell you what's wrong but don't prevent any build/deployment - that's what pylint will do in that case
  2. focus on fixing the problems up to the point where you can put a strict rule, one type of problems at a time
  3. enforce one specific rule and make it mandatory, making any build/deployment impossible if the code doesn't follow this new rule

Flake 8 is best at step 3, because we rely on it to validate the code before merge & packaging. Pylint is best for 1 & 2 as it generate a report you can use from time to time to know what's wrong and what you can fix.

@dgw
Copy link
Member Author

dgw commented Feb 25, 2021

I'm going to leave the rest of this stuff for 8.0. We put in a ton of doc/docstring work for 7.1, and I'd rather go over things again to fix warnings after we remove the deprecated stuff that's due for deletion in 8.0. 🙃

@dgw dgw modified the milestones: 7.1.0, 8.0.0 Feb 25, 2021
@dgw
Copy link
Member Author

dgw commented Feb 24, 2022

In case my closing note for #1978 wasn't clear enough, the target approach for docstrings at this moment is going to be those first 2 steps @Exirel mentioned. We'll probably want to avoid monolithic PRs for any of these, which means I fully expect the milestone to float along as we decide stuff is ready to ship and move to the next version.

@dgw dgw added the Long-term Planning Things that need to happen at some point in the future, but need to NOT happen soon. label Feb 24, 2022
@dgw dgw mentioned this issue May 19, 2022
4 tasks
@Exirel
Copy link
Contributor

Exirel commented Jul 14, 2022

I've added flake8-quotes in #2322.

@Exirel Exirel mentioned this issue Jul 14, 2022
4 tasks
@dgw dgw removed this from the 8.0.0 milestone Jul 15, 2022
@dgw
Copy link
Member Author

dgw commented Jul 15, 2022

Because this won't affect the software in any way, I've decided it needn't be part of any milestone. "Tracking" and "Long-term Planning" labels both indicate it's more of a wishlist, not part of any specific roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Long-term Planning Things that need to happen at some point in the future, but need to NOT happen soon. Low Priority Tests Tracking Tweak
Projects
None yet
Development

No branches or pull requests

3 participants