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

lint (black/pyflakes) everything that looks like python code using pre-commit #1461

Merged
merged 16 commits into from
Oct 22, 2020

Conversation

graingert
Copy link
Member

@graingert graingert commented Oct 22, 2020

Contributor Checklist:

@graingert
Copy link
Member Author

graingert commented Oct 22, 2020

I was somewhat conflicted on fixing the historic/2003 python docs - but the changes made to make them syntactically valid under python3 are so minimal that I think it's worth doing.

I'd rather delete them than shade them from the light of black

@graingert graingert changed the title Black everything lint everything that looks like python code Oct 22, 2020
@graingert graingert changed the title lint everything that looks like python code lint (black/pyflakes) everything that looks like python code using pre-commit Oct 22, 2020
.pre-commit-config.yaml Outdated Show resolved Hide resolved
@graingert graingert closed this Oct 22, 2020
@graingert graingert reopened this Oct 22, 2020
Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! Great stuff :)

Happy to see this and I think that this PR is on the right path

A have a few major comments before approving this.

See inline comments.

Thanks!

@@ -10,7 +10,7 @@ jobs:
lint:
runs-on: ubuntu-20.04
env:
TOXENV: "lint,black,twine"
TOXENV: "lint,twine"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need twine here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. twine runs other checks on the built wheel and doesn't really fit with the pre-commit model

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I guess this will be removed in the followup PR with the new wheel+sdist build workflow... or am O lost ? ... again :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm keeping twine still in the release PR too

.github/PULL_REQUEST_TEMPLATE Show resolved Hide resolved
Or, for speed, specify exactly what to format::

$ tox -e black-reformat -- path/to/file.py
$ pipx run pre-commit run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a tox pre-commit env as the "standard" tool... pipx is great, but I think that is best to keep all in tox.

People who will want to run pipx or just custom virtualenv could then use the rules from tox to see how to run-precommit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tox -e lint -- run does that already

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Them maybe suggest

Suggested change
$ pipx run pre-commit run
$ tox -e lint -- run

I would prefer tox -e lint to only run on changes since trunk. and have tox -e lint --all-files to be used by CI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running via tox instead of pipx adds quite a bit of slowness - pipx here is more of a demo on how it could be installed.

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flake8 runs only pyflakes by default ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, flake8 runs pycodestyle and pyflakes, Ive ignored all the pycodestyle violations that currently stand, and double checked the pyflakes violations are not ignored

@adiroiban
Copy link
Member

I'd rather delete them than shade them from the light of black

I think we can keep them...since they are historic. ... but is ok to update then with black.
If we remove, them I think that should be done in a separate PR.

Thanks!

Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Only minor comments.

This is ready for merge.

setup.cfg Show resolved Hide resolved
Or, for speed, specify exactly what to format::

$ tox -e black-reformat -- path/to/file.py
$ pipx run pre-commit run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Them maybe suggest

Suggested change
$ pipx run pre-commit run
$ tox -e lint -- run

I would prefer tox -e lint to only run on changes since trunk. and have tox -e lint --all-files to be used by CI.

admin/fix-for-src-mv.py Outdated Show resolved Hide resolved
Co-authored-by: Adi Roiban <adiroiban@gmail.com>
@graingert graingert merged commit d4cf03c into twisted:trunk Oct 22, 2020
@graingert graingert deleted the black-everything branch October 22, 2020 17:09
@rodrigc
Copy link
Contributor

rodrigc commented Jan 3, 2021

@graingert You removed the tox -e black target, but you didn't update the places on the wiki where this target is mentioned: https://twistedmatrix.com/trac/wiki/TwistedDevelopment

Do you plan to update the wiki?

@adiroiban / @wsanchez When reviewing this type of stuff, please double check that any documentation changes on the wiki are updated as well.

@adiroiban
Copy link
Member

adiroiban commented Jan 3, 2021

Thanks for the followup. Well, we do our best with the review

I think that anyone can update the Wiki without the need for a review... so feel free to update the wiki page.


I would like to stop using the wiki and instead use the repo's docs for documentation.

In this way, everything can be done in a single PR.

We now have up to date docs based on the trunk branch at

https://docs.twistedmatrix.com/en/latest/core/development/index.html

@graingert
Copy link
Member Author

graingert commented Jan 3, 2021

I would like to stop using the wiki and instead use the repo's docs for documentation.

I tend to agree, in this case I think we should delete the outdated wiki version of these docs and link to the updated version on https://docs.twistedmatrix.com/

@rodrigc
Copy link
Contributor

rodrigc commented Jan 3, 2021

@graingert for now, can you update the wiki as I have asked? While not perfect, the wiki has been around for a long time,
and for better or worse, many people in the project, and outside the project still refer to it.

The Twisted Development process is a very important part of the Twisted project. If this is deleted from the wiki
in favor of documentation inside the tree, then this needs to be done via a ticket and PR (just like anything else in Twisted),
so that there is an audit trail that this has been decided and agreed upon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants