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

Add files for pre-commit configuration (pylint and black) #2567

Merged
merged 15 commits into from
May 17, 2022

Conversation

antalszava
Copy link
Contributor

@antalszava antalszava commented May 12, 2022

Context:

The pre-commit package allows installing git pre-commit hooks. Such a hook refers to running dedicated tools (e.g., pylint and black) each time a developer issues the git commit command locally. If the run for one of the tools fails, then committing fails too. The hook for black automatically applies black.

Description of the Change:

Adds a

  • .pre-commit-config.yaml top level file
  • pyproject.toml top level file

Extends the documentation of creating a pull request to mention the use of pre-commit.

Benefits:

An easy and standardized way of configuring git pre-commit hooks for PennyLane developers.

Possible Drawbacks:

As noted in the docs entry, as new versions of black are being released, pre-commit autoupdate may have to be reissued because pre-commit installs packages

Related GitHub Issues:
N/A

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #2567 (9e2039f) into master (6892a0c) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #2567   +/-   ##
=======================================
  Coverage   99.58%   99.58%           
=======================================
  Files         243      243           
  Lines       19595    19595           
=======================================
  Hits        19514    19514           
  Misses         81       81           

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 6892a0c...9e2039f. Read the comment docs.

@antalszava
Copy link
Contributor Author

[sc-19544]

@antalszava antalszava marked this pull request as ready for review May 13, 2022 18:40
@albi3ro
Copy link
Contributor

albi3ro commented May 13, 2022

@antalszava When I ran pre-commit run --all-files locally, it also styled:

reformatted doc/_static/style/style_examples.py
reformatted doc/_static/draw_mpl/draw_mpl_examples.py
reformatted doc/_static/tape_mpl/tape_mpl_examples.py
reformatted doc/conf.py
reformatted doc/_static/drawer/mpldrawer_examples.py

I personally see no problem with those files being styled as well, but the regular expression in pyproject.toml may need changing if we want to limit it to pennylane and tests.

Copy link
Contributor

@rmoyard rmoyard left a comment

Choose a reason for hiding this comment

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

It looks all good, I've added some suggestions. Same as @albi3ro, if I run the all file options, the docs are included and I have both pylint and black errors. Is it possible to change the definition of all files in the config?

doc/development/guide/pullrequests.rst Show resolved Hide resolved
doc/development/guide/pullrequests.rst Show resolved Hide resolved
@antalszava
Copy link
Contributor Author

Thank you @albi3ro and @rmoyard for the catch and the comments! I've updated the exclude patterns and extended the description in the docs.

@antalszava antalszava requested a review from rmoyard May 16, 2022 13:56
Copy link
Contributor

@rmoyard rmoyard left a comment

Choose a reason for hiding this comment

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

@antalszava Thank you, it looks all good 💯

@antalszava antalszava merged commit bcd837b into master May 17, 2022
@antalszava antalszava deleted the pre_commit_setup_files branch May 17, 2022 13:17
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.

3 participants