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

pre-commit run --all-files fails on main branch #1674

Closed
vonschultz opened this issue Jan 8, 2024 · 4 comments · Fixed by #1859
Closed

pre-commit run --all-files fails on main branch #1674

vonschultz opened this issue Jan 8, 2024 · 4 comments · Fixed by #1859
Labels
cleanup Tech debt, resolving it improves our own velocity help wanted

Comments

@vonschultz
Copy link
Contributor

🐞 bug report

Description

Running pre-commit run --all-files produces errors from incorrectly formatted Python files, with both black and isort complaining. If a project uses pre-commit, I would expect the state of the main branch to pass all the pre-commit checks, to facilitate further development.

🔬 Minimal Reproduction

Check out the main branch, at the time of writing 69edec8. Make sure git status reports a clean tree. Run pre-commit run --all-files. Expected behavior is to see all checks "Passed".

🔥 Exception or Error

~/src/github.com/bazelbuild/rules_python$ pre-commit run --all-files
buildifier...............................................................Passed
buildifier-lint..........................................................Passed
isort (python)...........................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /home/von/src/github.com/bazelbuild/rules_python/examples/build_file_generation/__init__.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/examples/build_file_generation/__test__.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/examples/build_file_generation/random_number_generator/__test__.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/examples/bzlmod/__main__.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/examples/bzlmod/lib.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/examples/py_proto_library/message_test.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/gazelle/python/parse_test.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/gazelle/python/testdata/binary_without_entrypoint/main_test.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/gazelle/python/testdata/python_target_with_test_in_name/real_test.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/gazelle/python/testdata/relative_imports/package2/module3.py
Fixing /home/von/src/github.com/bazelbuild/rules_python/gazelle/python/testdata/sibling_imports/pkg/unit_test.py

black....................................................................Failed
- hook id: black
- files were modified by this hook

reformatted gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py
reformatted gazelle/python/testdata/first_party_file_and_directory_modules/baz.py
reformatted gazelle/python/testdata/per_file_subdirs/bar/foo.py
reformatted gazelle/python/testdata/first_party_file_and_directory_modules/foo.py
reformatted gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py
reformatted gazelle/python/testdata/python_target_with_test_in_name/test_reality.py
reformatted gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py
reformatted examples/py_proto_library/message_test.py
reformatted gazelle/python/testdata/generated_test_entrypoint/foo.py
reformatted gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py
reformatted examples/build_file_generation/__init__.py
reformatted gazelle/python/testdata/naming_convention/__main__.py
reformatted examples/build_file_generation/__main__.py
reformatted gazelle/python/testdata/naming_convention/__test__.py
reformatted gazelle/python/testdata/binary_without_entrypoint/collided_main.py
reformatted gazelle/python/testdata/naming_convention/dont_rename/__main__.py
reformatted examples/build_file_generation/random_number_generator/__init__.py
reformatted gazelle/python/testdata/binary_without_entrypoint/main.py
reformatted gazelle/python/testdata/naming_convention/dont_rename/__test__.py
reformatted examples/build_file_generation/random_number_generator/__test__.py
reformatted gazelle/python/testdata/binary_without_entrypoint/main_test.py
reformatted gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py
reformatted examples/build_file_generation/random_number_generator/generate_random_number.py
reformatted gazelle/python/testdata/dont_rename_target/__init__.py
reformatted gazelle/python/testdata/sibling_imports/pkg/b.py
reformatted gazelle/python/testdata/relative_imports/package1/module2.py
reformatted gazelle/python/testdata/simple_test_with_conftest/conftest.py
reformatted gazelle/python/testdata/respect_kind_mapping/foo.py
reformatted python/pip_install/tools/dependency_resolver/__init__.py
reformatted gazelle/python/testdata/relative_imports/package2/module4.py
reformatted gazelle/python/testdata/simple_test/foo.py
reformatted gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py
reformatted gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py
reformatted gazelle/python/testdata/simple_test_with_conftest/foo.py
reformatted examples/build_file_generation/__test__.py
reformatted gazelle/python/testdata/relative_imports/package2/__init__.py
reformatted tests/pycross/patched_py_wheel_library_test.py
reformatted examples/wheel/private/directory_writer.py
reformatted examples/pip_parse/pip_parse_test.py
reformatted examples/bzlmod_build_file_generation/runfiles/runfiles_test.py
reformatted gazelle/python/parse.py
reformatted python/pip_install/tools/dependency_resolver/dependency_resolver.py

All done! ✨ 🍰 ✨
42 files reformatted, 212 files left unchanged.

Update deleted packages..................................................Failed
- hook id: update-deleted-packages
- exit code: 1

Executable `/home/von/src/github.com/bazelbuild/rules_python/bazel` not found

🌍 Your Environment

Operating System:

~/src/github.com/bazelbuild/rules_python$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal

Output of bazel version:

~/src/github.com/bazelbuild/rules_python$ bazelisk version
Bazelisk version: v1.19.0
Starting local Bazel server and connecting to it...
Build label: 7.0.0
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Dec 11 16:51:49 2023 (1702313509)
Build timestamp: 1702313509
Build timestamp as int: 1702313509

Rules_python version:

Latest main (69edec8 at the time of writing)

Anything else relevant?

~/src/github.com/bazelbuild/rules_python$ pre-commit --version
pre-commit 3.5.0
@aignas aignas added help wanted cleanup Tech debt, resolving it improves our own velocity labels Jan 16, 2024
@chethanagopinath
Copy link

@aignas could I pick this up? To ask questions on how I can start, can I reach out in this issue thread? (or on slack?)

@rickeylev
Copy link
Contributor

Yep, go for it! Feel free to keep notes in the contributing.md on your experience (the sections on setting up pyenv and pre-commit came from my experience getting started, but they're incomplete as I forgot some details).

@dougthor42
Copy link
Contributor

@chethanagopinath Do you still plan on working on this? I'd be happy to take it over if you don't have time.

@chethanagopinath
Copy link

chethanagopinath commented Apr 17, 2024

@dougthor42 This issue seems to have dropped off my radar for some reason. Thanks for reaching out, please feel free to pick it up.

github-merge-queue bot pushed a commit that referenced this issue Apr 17, 2024
Run `isort` and `black` on all python files so that the pre-commit
hooks do not fail anymore.

It seems like most of the issues were quotation marks and vertical
whitespace.

Fixes #1674.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Tech debt, resolving it improves our own velocity help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants