Skip to content

Add pre-commit configuration file #1593

Closed

Description

@willschlitzer

To prevent the annoyance of realizing I forgot to run black after I have pushed a commit, I think it would be good to add a pre-commit hook configuration file to automatically run black, flake8, and other formatting packages.

Are you willing to help implement and maintain this feature? Yes

Activity

  1. weiji14 commented on Oct 28, 2021

    @weiji14
    Member

    We'll need to discuss whether to add this. I recognize the value of using pre-commit, but I find that it is another layer of friction for new contributors to set up locally. Black is quite fast to run, but pylint can be very slow and I'd hate to run it every commit! We could also look at streamlining/improving the /format slash command if that's an issue.

  2. added
    question
    on Oct 28, 2021
  3. willschlitzer commented on Oct 29, 2021

    @willschlitzer
    ContributorAuthor

    We'll need to discuss whether to add this. I recognize the value of using pre-commit, but I find that it is another layer of friction for new contributors to set up locally. Black is quite fast to run, but pylint can be very slow and I'd hate to run it every commit! We could also look at streamlining/improving the /format slash command if that's an issue.

    I think of it as an optional add; contributors can choose to use pre-commit and already have a configuration file already to go. But I agree that making its usage mandatory is another barrier for entry for new contributors.

  4. maxrjones commented on Nov 1, 2021

    @maxrjones
    Member

    We'll need to discuss whether to add this. I recognize the value of using pre-commit, but I find that it is another layer of friction for new contributors to set up locally. Black is quite fast to run, but pylint can be very slow and I'd hate to run it every commit! We could also look at streamlining/improving the /format slash command if that's an issue.

    Does the /format slash command not work for forks? I haven't had much success with using it lately.

  5. willschlitzer commented on Nov 19, 2021

    @willschlitzer
    ContributorAuthor

    I tried this out on my local machine and it wasn't as user friendly as I hoped. I'm sure it can be configured to work alongside our make commands, but I'm going to close this issue since there doesn't seem to be much interest in it.

  6. maxrjones commented on Aug 12, 2022

    @maxrjones
    Member

    I've started using pre-commit while working on some other repositories and find it really nice. If there turns out to be interest from others in this tool, I could help set it up for the repository. I think it may be less friction for new contributors (install pre-commit and run pre-commit install once) than remembering the make commands given that it's getting to be fairly common.

  7. weiji14 commented on Aug 17, 2022

    @weiji14
    Member
  8. maxrjones commented on Aug 17, 2022

    @maxrjones
    Member

    Is it worth trying https://pre-commit.ci/?

    Yes, I think we could try this as an alternative to the format slash command and probably the style checks workflow.

  9. seisman commented on Jun 14, 2023

    @seisman
    Member

    I recognize the value of using pre-commit, but I find that it is another layer of friction for new contributors to set up locally. Black is quite fast to run, but pylint can be very slow and I'd hate to run it every commit!

    I agree.

    Is it worth trying https://pre-commit.ci/?

    Yes, I think we could try this as an alternative to the format slash command and probably the style checks workflow.

    The pre-commit.ci service commits changes directly to the branch that triggers the CI, which means that the PR authors must update their local branch (e.g., git pull) before pushing more changes to remote (i.e., git push), otherwise they will see errors like:

    error: failed to push some refs to '[email protected]:xxx/xxx.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    which are not friendly for git newbies.

    In short, I'm inclined to not use pre-commit and close the issue.

  10. maxrjones commented on Jun 14, 2023

    @maxrjones
    Member

    The pre-commit.ci service commits changes directly to the branch that triggers the CI, which means that the PR authors must update their local branch (e.g., git pull) before pushing more changes to remote (i.e., git push), otherwise they will see errors like:

    This is configurable and can be disabled so that the CI service doesn't push changes, but I'll close this since I was the one encouraging using pre-commit and haven't been working on PyGMT lately.

  11. reopened this on Jun 4, 2024
  12. weiji14 commented on Jun 4, 2024

    @weiji14
    Member

    And... we're back! Continuing on from #3278, it sounds like the team is finally warming up to adding a .pre-commit-config.yaml file and installing the pre-commit.ci service.

    Question: Do we want to replace the /format slash workflow with pre-commit.ci? Probably depends on whether pre-commit.ci works on forks (we can keep both first, and test to see how it works on forks).

  13. added
    maintenance
    and removed
    question
    feature request
    on Jun 4, 2024
  14. added this to the 0.13.0 milestone on Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

maintenance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions