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

Improve pre-commit config #9563

Merged
merged 4 commits into from Jan 18, 2023
Merged

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jan 18, 2023

  • Add a few more hooks. These are all very fast, and I've found them useful in other projects:
    • Autofixes:
      • trailing-whitespace: fixes trailing whitespace
      • requirements-txt-fixer: alphabetises items in requirements.txt files
      • end-of-file-fixer: makes sure every file ends with a single newline character
      • mixed-line-ending: Makes sure Windows users don't accidentally introduce CRLF line endings into a file that uses LF line endings
    • None-autofixes:
      • check-yaml: loads YAML files to validate syntax
      • check-toml: loads TOML files to validate syntax
      • check-merge-conflict: detects merge-conflict strings in files and blocks them from accidentally being committed
      • check-case-conflict: checks for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT; blocks them from being committed.
    • Change the bot schedule to quarterly, to reduce noisy PRs
    • Change the black language target-version to Python 3.10, synching the setting here with the changes that were made to our pyproject.toml file in Update black target version to py310 #7538

@AlexWaygood AlexWaygood marked this pull request as draft January 18, 2023 13:42
@AlexWaygood AlexWaygood marked this pull request as ready for review January 18, 2023 13:51
@@ -220,8 +221,9 @@ def get_precommit_requirements() -> dict[str, SpecifierSet]:
if not repo.get("python_requirement", True):
continue
hook = repo["hooks"][0]
package_name, package_rev = hook["id"], repo["rev"]
package_specifier = SpecifierSet(f"=={package_rev.removeprefix('v')}")
package_name = Path(urllib.parse.urlparse(repo["repo"]).path).name
Copy link
Member

Choose a reason for hiding this comment

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

Is this meant to be part of this PR?

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. The test as it currently stands is poorly designed. Without this change, check_consistent.py fails if we add pre-commit-hooks to our pre-commit config, because of the fact that the hooks in the pre-commit-hooks repo have different names to the repo as a whole.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks!

@JelleZijlstra JelleZijlstra merged commit a4e3cfe into python:main Jan 18, 2023
86 checks passed
@AlexWaygood AlexWaygood deleted the precommit-config branch January 18, 2023 14:30
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

2 participants