rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

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

Open vonschultz opened this issue 2 years ago • 2 comments

🐞 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 69edec83713d2feaa44f8126c602dbc27f4a966c. 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 (69edec83713d2feaa44f8126c602dbc27f4a966c at the time of writing)

Anything else relevant?

~/src/github.com/bazelbuild/rules_python$ pre-commit --version
pre-commit 3.5.0

vonschultz avatar Jan 08 '24 14:01 vonschultz

@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?)

chethanagopinath avatar Jan 17 '24 10:01 chethanagopinath

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).

rickeylev avatar Jan 17 '24 18:01 rickeylev

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

dougthor42 avatar Apr 17 '24 16:04 dougthor42

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

chethanagopinath avatar Apr 17 '24 17:04 chethanagopinath