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

Simplify Makefile and requirements #5145

Merged
merged 13 commits into from
Oct 28, 2020
Merged

Simplify Makefile and requirements #5145

merged 13 commits into from
Oct 28, 2020

Conversation

asvetlov
Copy link
Member

@asvetlov asvetlov commented Oct 25, 2020

No description provided.

Comment on lines +25 to +38
- id: requirements-txt-fixer
- id: file-contents-sorter
files: CONTRIBUTORS.txt
# Another entry is required to apply file-contents-sorter to another file
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.3.0'
hooks:
- id: file-contents-sorter
files: docs/spelling_wordlist.txt
- repo: https://github.com/asottile/pyupgrade
rev: 'v2.7.3'
hooks:
- id: pyupgrade
args: ['--py36-plus']
Copy link
Member

Choose a reason for hiding this comment

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

Putting the formatters at the end is usually a bad idea. Because the linters will then check the contents as they were before formatting making it rather inconsistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

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've pushed flake8 at the last position, all previous hooks eighter modifies python source or don't check them

Copy link
Member

Choose a reason for hiding this comment

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

Oh, and another piece of advice: you can split the hooks from the same repo into two and put in different places if needed. Within the blocks of mutating and non-mutating checks, I normally sort the individual hooks so that the fastest ones would go first. This maximizes the responsiveness of the process.

Copy link
Member

@webknjaz webknjaz Oct 26, 2020

Choose a reason for hiding this comment

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

One more thing: you can have a separate pre-commit config for very heavy checks and would be nice to always run in CI but users would only invoke them on-demand.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got you

Makefile Outdated
lint: isort-check black-check flake8 mypy
.PHONY: pre-commit
pre-commit:
pre-commit run --all-files
Copy link
Member

Choose a reason for hiding this comment

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

Here's a recommended invocation example: https://github.com/ansible/pylibssh/blob/bd53dd8/tox.ini#L236. It's especially useful to have --show-diff-on-failure in CI, less so locally but it also comes in handy to review what mutations have been applied.
Also, dunno how it's possible with make but in tox it's common to allow end-users to bypass their own args to pre-commit so while tox -e lint runs pre-commit run --all-files, tox -e lint -- flake8 --files x/y/z would run pre-commit run flake8 --files x/y/z which is useful when trying to go through what a specfic linter reports separately in a more responsive manner.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, thanks!

@codecov-io
Copy link

codecov-io commented Oct 26, 2020

Codecov Report

Merging #5145 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5145   +/-   ##
=======================================
  Coverage   97.56%   97.56%           
=======================================
  Files          43       43           
  Lines        8780     8780           
  Branches     1412     1412           
=======================================
  Hits         8566     8566           
  Misses        100      100           
  Partials      114      114           
Flag Coverage Δ
#unit 97.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f916f5b...8c26b43. Read the comment docs.

@asvetlov asvetlov merged commit 4698c2c into master Oct 28, 2020
@asvetlov asvetlov deleted the simplify-reqs branch October 28, 2020 07:59
@github-actions
Copy link
Contributor

💔 Backport was not successful

The PR was attempted backported to the following branches:

  • ❌ 3.7: Commit could not be cherrypicked due to conflicts
  • ❌ 3.8: Commit could not be cherrypicked due to conflicts

asvetlov added a commit that referenced this pull request Oct 28, 2020
asvetlov added a commit that referenced this pull request Oct 28, 2020
@weastur weastur mentioned this pull request Mar 31, 2021
5 tasks
commonism pushed a commit to commonism/aiohttp that referenced this pull request Apr 27, 2021
commonism pushed a commit to commonism/aiohttp that referenced this pull request Apr 27, 2021
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

3 participants