diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f0c2e0e2a..1f577f2120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ A brief description of the categories of changes: `pip.parse` extension is now possible, see the `examples/pip_parse/MODULE.bazel` for how to do it. See [#1371](https://github.com/bazelbuild/rules_python/issues/1371). +* (refactor) The pre-commit developer workflow should now pass `isort` and `black` + checks (see [#1674](https://github.com/bazelbuild/rules_python/issues/1674)). ### Added diff --git a/examples/build_file_generation/__init__.py b/examples/build_file_generation/__init__.py index 37dea1b0de..22e42212de 100644 --- a/examples/build_file_generation/__init__.py +++ b/examples/build_file_generation/__init__.py @@ -12,16 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sphinx # noqa from flask import Flask, jsonify from random_number_generator import generate_random_number -import sphinx # noqa app = Flask(__name__) -@app.route('/random-number', methods=['GET']) + +@app.route("/random-number", methods=["GET"]) def get_random_number(): - return jsonify({'number': generate_random_number.generate_random_number()}) + return jsonify({"number": generate_random_number.generate_random_number()}) + -"""Start the python web server""" def main(): + """Start the python web server""" app.run() diff --git a/examples/build_file_generation/__main__.py b/examples/build_file_generation/__main__.py index 8f8efbaaa3..a77055f2d5 100644 --- a/examples/build_file_generation/__main__.py +++ b/examples/build_file_generation/__main__.py @@ -14,5 +14,5 @@ from __init__ import main -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/examples/build_file_generation/__test__.py b/examples/build_file_generation/__test__.py index c4fa5ef9b5..45e127bab8 100644 --- a/examples/build_file_generation/__test__.py +++ b/examples/build_file_generation/__test__.py @@ -13,16 +13,19 @@ # limitations under the License. import unittest + from __init__ import app + class TestServer(unittest.TestCase): def setUp(self): self.app = app.test_client() - + def test_get_random_number(self): - response = self.app.get('/random-number') + response = self.app.get("/random-number") self.assertEqual(response.status_code, 200) - self.assertIn('number', response.json) - -if __name__ == '__main__': + self.assertIn("number", response.json) + + +if __name__ == "__main__": unittest.main() diff --git a/examples/build_file_generation/random_number_generator/__init__.py b/examples/build_file_generation/random_number_generator/__init__.py index bbdfb4c588..41010956cf 100644 --- a/examples/build_file_generation/random_number_generator/__init__.py +++ b/examples/build_file_generation/random_number_generator/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/examples/build_file_generation/random_number_generator/__test__.py b/examples/build_file_generation/random_number_generator/__test__.py index 8cfb235d57..5facfeee9e 100644 --- a/examples/build_file_generation/random_number_generator/__test__.py +++ b/examples/build_file_generation/random_number_generator/__test__.py @@ -13,13 +13,16 @@ # limitations under the License. import unittest + import random_number_generator.generate_random_number as generate_random_number + class TestRandomNumberGenerator(unittest.TestCase): def test_generate_random_number(self): number = generate_random_number.generate_random_number() self.assertGreaterEqual(number, 1) self.assertLessEqual(number, 10) - -if __name__ == '__main__': + + +if __name__ == "__main__": unittest.main() diff --git a/examples/build_file_generation/random_number_generator/generate_random_number.py b/examples/build_file_generation/random_number_generator/generate_random_number.py index e198b5bbcd..d551e3367f 100644 --- a/examples/build_file_generation/random_number_generator/generate_random_number.py +++ b/examples/build_file_generation/random_number_generator/generate_random_number.py @@ -14,6 +14,7 @@ import random -"""Generate a random number""" + def generate_random_number(): + """Generate a random number""" return random.randint(1, 10) diff --git a/examples/bzlmod/__main__.py b/examples/bzlmod/__main__.py index daf17495c2..2dd322adc6 100644 --- a/examples/bzlmod/__main__.py +++ b/examples/bzlmod/__main__.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from lib import main import sys +from lib import main + if __name__ == "__main__": print(main([["A", 1], ["B", 2]])) print(sys.version) diff --git a/examples/bzlmod/lib.py b/examples/bzlmod/lib.py index 5f0167f4e7..e76042d8ec 100644 --- a/examples/bzlmod/lib.py +++ b/examples/bzlmod/lib.py @@ -12,8 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tabulate import tabulate import sphinx # noqa +from tabulate import tabulate + def main(table): return tabulate(table) diff --git a/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py b/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py index a588040cfd..5bfa5302ef 100644 --- a/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py +++ b/examples/bzlmod_build_file_generation/runfiles/runfiles_test.py @@ -26,7 +26,9 @@ def testCurrentRepository(self): self.assertEqual(runfiles.Create().CurrentRepository(), "") def testRunfilesWithRepoMapping(self): - data_path = runfiles.Create().Rlocation("example_bzlmod_build_file_generation/runfiles/data/data.txt") + data_path = runfiles.Create().Rlocation( + "example_bzlmod_build_file_generation/runfiles/data/data.txt" + ) with open(data_path) as f: self.assertEqual(f.read().strip(), "Hello, example_bzlmod!") diff --git a/examples/multi_python_versions/tests/my_lib_test.py b/examples/multi_python_versions/tests/my_lib_test.py index 3f334f531f..449cb8473c 100644 --- a/examples/multi_python_versions/tests/my_lib_test.py +++ b/examples/multi_python_versions/tests/my_lib_test.py @@ -23,7 +23,9 @@ if not my_lib.websockets_is_for_python_version( workspace_version ) and not my_lib.websockets_is_for_python_version(bzlmod_version): - print("expected package for Python version is different than returned\n" - f"expected either {workspace_version} or {bzlmod_version}\n" - f"but got {my_lib.websockets.__file__}") + print( + "expected package for Python version is different than returned\n" + f"expected either {workspace_version} or {bzlmod_version}\n" + f"but got {my_lib.websockets.__file__}" + ) sys.exit(1) diff --git a/examples/pip_parse/pip_parse_test.py b/examples/pip_parse/pip_parse_test.py index 79e1a754ab..2fdd45477e 100644 --- a/examples/pip_parse/pip_parse_test.py +++ b/examples/pip_parse/pip_parse_test.py @@ -28,10 +28,7 @@ class PipInstallTest(unittest.TestCase): def _remove_leading_dirs(self, paths): # Removes the first two directories (external/) # to normalize what workspace and bzlmod produce. - return [ - '/'.join(v.split('/')[2:]) - for v in paths - ] + return ["/".join(v.split("/")[2:]) for v in paths] def test_entry_point(self): entry_point_path = os.environ.get("YAMLLINT_ENTRY_POINT") diff --git a/examples/py_proto_library/message_test.py b/examples/py_proto_library/message_test.py index 3aee1ee8c5..b1a6942a54 100644 --- a/examples/py_proto_library/message_test.py +++ b/examples/py_proto_library/message_test.py @@ -3,13 +3,14 @@ from another_proto import message_pb2 + class TestCase(unittest.TestCase): def test_message(self): got = message_pb2.TestMessage( - index = 5, + index=5, ) self.assertIsNotNone(got) if __name__ == "__main__": - sys.exit(unittest.main()) + sys.exit(unittest.main()) diff --git a/examples/wheel/private/directory_writer.py b/examples/wheel/private/directory_writer.py index 7d9a93ed3f..4b69f3a5d0 100644 --- a/examples/wheel/private/directory_writer.py +++ b/examples/wheel/private/directory_writer.py @@ -48,7 +48,7 @@ def main() -> None: args.output.mkdir(parents=True, exist_ok=True) - for (path, content) in args.files: + for path, content in args.files: new_file = args.output / path new_file.parent.mkdir(parents=True, exist_ok=True) new_file.write_text(content) diff --git a/examples/wheel/wheel_test.py b/examples/wheel/wheel_test.py index e135eaad64..66ebd5044d 100644 --- a/examples/wheel/wheel_test.py +++ b/examples/wheel/wheel_test.py @@ -62,7 +62,7 @@ def assertAllEntriesHasReproducibleMetadata(self, zf): self.assertEqual( zinfo.external_attr, (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | stat.S_IFREG) << 16, - msg=zinfo.filename + msg=zinfo.filename, ) self.assertEqual( zinfo.compress_type, zipfile.ZIP_DEFLATED, msg=zinfo.filename @@ -486,7 +486,7 @@ def test_minimal_data_files(self): "minimal_data_files-0.0.1.data/data/target/path/README.md", "minimal_data_files-0.0.1.data/scripts/NOTICE", "minimal_data_files-0.0.1.dist-info/RECORD", - ] + ], ) diff --git a/gazelle/manifest/copy_to_source.py b/gazelle/manifest/copy_to_source.py index 6854192332..4ebb958c3d 100644 --- a/gazelle/manifest/copy_to_source.py +++ b/gazelle/manifest/copy_to_source.py @@ -26,7 +26,7 @@ def copy_to_source(generated_relative_path: Path, target_relative_path: Path) -> target_absolute_path.parent.mkdir(parents=True, exist_ok=True) shutil.copy(generated_absolute_path, target_absolute_path) - target_absolute_path.chmod(0O664) + target_absolute_path.chmod(0o664) if __name__ == "__main__": diff --git a/gazelle/python/parse.py b/gazelle/python/parse.py index daa6d2b47c..77fc92005f 100644 --- a/gazelle/python/parse.py +++ b/gazelle/python/parse.py @@ -72,7 +72,7 @@ def parse_main(content): if token_type != OP or token_val != "==": continue token_type, token_val, start, _, _ = next(g) - if token_type != STRING or token_val.strip("\"'") != '__main__': + if token_type != STRING or token_val.strip("\"'") != "__main__": continue token_type, token_val, start, _, _ = next(g) if token_type != OP or token_val != ":": diff --git a/gazelle/python/parse_test.py b/gazelle/python/parse_test.py index 3ebded44b3..6d1fa49547 100644 --- a/gazelle/python/parse_test.py +++ b/gazelle/python/parse_test.py @@ -1,6 +1,8 @@ import unittest + import parse + class TestParse(unittest.TestCase): def test_not_has_main(self): content = "a = 1\nb = 2" diff --git a/gazelle/python/testdata/binary_without_entrypoint/collided_main.py b/gazelle/python/testdata/binary_without_entrypoint/collided_main.py index 3bf59c7795..ba732516c4 100644 --- a/gazelle/python/testdata/binary_without_entrypoint/collided_main.py +++ b/gazelle/python/testdata/binary_without_entrypoint/collided_main.py @@ -1,4 +1,4 @@ import numpy if __name__ == "__main__": - run() \ No newline at end of file + run() diff --git a/gazelle/python/testdata/binary_without_entrypoint/main.py b/gazelle/python/testdata/binary_without_entrypoint/main.py index f7b317062b..49f1049475 100644 --- a/gazelle/python/testdata/binary_without_entrypoint/main.py +++ b/gazelle/python/testdata/binary_without_entrypoint/main.py @@ -2,4 +2,4 @@ import pandas if __name__ == "__main__": - run() \ No newline at end of file + run() diff --git a/gazelle/python/testdata/binary_without_entrypoint/main_test.py b/gazelle/python/testdata/binary_without_entrypoint/main_test.py index 505a766319..a010fe71de 100644 --- a/gazelle/python/testdata/binary_without_entrypoint/main_test.py +++ b/gazelle/python/testdata/binary_without_entrypoint/main_test.py @@ -1,7 +1,9 @@ import unittest + class TestMain(unittest.unittest): pass + if __name__ == "__main__": unittest.main() diff --git a/gazelle/python/testdata/dont_rename_target/__init__.py b/gazelle/python/testdata/dont_rename_target/__init__.py index bbdfb4c588..41010956cf 100644 --- a/gazelle/python/testdata/dont_rename_target/__init__.py +++ b/gazelle/python/testdata/dont_rename_target/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py b/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py index e03a9ecb9d..8f8820d3f4 100644 --- a/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def baz(): return "baz from baz.py" diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py b/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py index 04474d83a8..be6d7dda45 100644 --- a/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def foo(): print("foo") diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py b/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py index 94cca3d002..d1909b1ab2 100644 --- a/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def two(): return "two" diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py index 76c72273fa..c5ccb8792f 100644 --- a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def find_me(): return "found" diff --git a/gazelle/python/testdata/generated_test_entrypoint/foo.py b/gazelle/python/testdata/generated_test_entrypoint/foo.py index 932de45b74..3f049df738 100644 --- a/gazelle/python/testdata/generated_test_entrypoint/foo.py +++ b/gazelle/python/testdata/generated_test_entrypoint/foo.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def foo(): return "foo" diff --git a/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py index bbdfb4c588..41010956cf 100644 --- a/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py +++ b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/gazelle/python/testdata/naming_convention/__main__.py b/gazelle/python/testdata/naming_convention/__main__.py index a3afc79dcd..97955897bf 100644 --- a/gazelle/python/testdata/naming_convention/__main__.py +++ b/gazelle/python/testdata/naming_convention/__main__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import __init__ \ No newline at end of file +import __init__ diff --git a/gazelle/python/testdata/naming_convention/__test__.py b/gazelle/python/testdata/naming_convention/__test__.py index a3afc79dcd..97955897bf 100644 --- a/gazelle/python/testdata/naming_convention/__test__.py +++ b/gazelle/python/testdata/naming_convention/__test__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import __init__ \ No newline at end of file +import __init__ diff --git a/gazelle/python/testdata/naming_convention/dont_rename/__main__.py b/gazelle/python/testdata/naming_convention/dont_rename/__main__.py index a3afc79dcd..97955897bf 100644 --- a/gazelle/python/testdata/naming_convention/dont_rename/__main__.py +++ b/gazelle/python/testdata/naming_convention/dont_rename/__main__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import __init__ \ No newline at end of file +import __init__ diff --git a/gazelle/python/testdata/naming_convention/dont_rename/__test__.py b/gazelle/python/testdata/naming_convention/dont_rename/__test__.py index a3afc79dcd..97955897bf 100644 --- a/gazelle/python/testdata/naming_convention/dont_rename/__test__.py +++ b/gazelle/python/testdata/naming_convention/dont_rename/__test__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import __init__ \ No newline at end of file +import __init__ diff --git a/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py b/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py index a3afc79dcd..97955897bf 100644 --- a/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py +++ b/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import __init__ \ No newline at end of file +import __init__ diff --git a/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py b/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py index a3afc79dcd..97955897bf 100644 --- a/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py +++ b/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import __init__ \ No newline at end of file +import __init__ diff --git a/gazelle/python/testdata/per_file_subdirs/bar/foo.py b/gazelle/python/testdata/per_file_subdirs/bar/foo.py index 59eb08c42f..506f02851b 100644 --- a/gazelle/python/testdata/per_file_subdirs/bar/foo.py +++ b/gazelle/python/testdata/per_file_subdirs/bar/foo.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def func(): pass diff --git a/gazelle/python/testdata/python_target_with_test_in_name/real_test.py b/gazelle/python/testdata/python_target_with_test_in_name/real_test.py index e390866be3..b25d5bd734 100644 --- a/gazelle/python/testdata/python_target_with_test_in_name/real_test.py +++ b/gazelle/python/testdata/python_target_with_test_in_name/real_test.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import boto3 import __init__ +import boto3 _ = boto3 diff --git a/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py b/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py index a3afc79dcd..97955897bf 100644 --- a/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py +++ b/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import __init__ \ No newline at end of file +import __init__ diff --git a/gazelle/python/testdata/relative_imports/package1/module2.py b/gazelle/python/testdata/relative_imports/package1/module2.py index f8893b24e6..0cbc5f0be0 100644 --- a/gazelle/python/testdata/relative_imports/package1/module2.py +++ b/gazelle/python/testdata/relative_imports/package1/module2.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def function2(): return "function2" diff --git a/gazelle/python/testdata/relative_imports/package2/__init__.py b/gazelle/python/testdata/relative_imports/package2/__init__.py index 0f5956835b..fcaa33000e 100644 --- a/gazelle/python/testdata/relative_imports/package2/__init__.py +++ b/gazelle/python/testdata/relative_imports/package2/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + class Class1: def method1(self): return "method1" diff --git a/gazelle/python/testdata/relative_imports/package2/module3.py b/gazelle/python/testdata/relative_imports/package2/module3.py index 478dea9aa6..29bb571a66 100644 --- a/gazelle/python/testdata/relative_imports/package2/module3.py +++ b/gazelle/python/testdata/relative_imports/package2/module3.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import resolved_package + from . import Class1 from .subpackage1.module5 import function5 -import resolved_package def function3(): c1 = Class1() diff --git a/gazelle/python/testdata/relative_imports/package2/module4.py b/gazelle/python/testdata/relative_imports/package2/module4.py index b7509dc7cf..28cdc13663 100644 --- a/gazelle/python/testdata/relative_imports/package2/module4.py +++ b/gazelle/python/testdata/relative_imports/package2/module4.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def function4(): return "function4" diff --git a/gazelle/python/testdata/respect_kind_mapping/foo.py b/gazelle/python/testdata/respect_kind_mapping/foo.py index 932de45b74..3f049df738 100644 --- a/gazelle/python/testdata/respect_kind_mapping/foo.py +++ b/gazelle/python/testdata/respect_kind_mapping/foo.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def foo(): return "foo" diff --git a/gazelle/python/testdata/sibling_imports/pkg/b.py b/gazelle/python/testdata/sibling_imports/pkg/b.py index 7095bdcfb2..d04d423678 100644 --- a/gazelle/python/testdata/sibling_imports/pkg/b.py +++ b/gazelle/python/testdata/sibling_imports/pkg/b.py @@ -1,2 +1,2 @@ def run(): - pass \ No newline at end of file + pass diff --git a/gazelle/python/testdata/sibling_imports/pkg/unit_test.py b/gazelle/python/testdata/sibling_imports/pkg/unit_test.py index a3218e2ec2..f42878aa1b 100644 --- a/gazelle/python/testdata/sibling_imports/pkg/unit_test.py +++ b/gazelle/python/testdata/sibling_imports/pkg/unit_test.py @@ -1,3 +1,3 @@ import a +import test_util from b import run -import test_util \ No newline at end of file diff --git a/gazelle/python/testdata/simple_test/foo.py b/gazelle/python/testdata/simple_test/foo.py index 932de45b74..3f049df738 100644 --- a/gazelle/python/testdata/simple_test/foo.py +++ b/gazelle/python/testdata/simple_test/foo.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def foo(): return "foo" diff --git a/gazelle/python/testdata/simple_test_with_conftest/conftest.py b/gazelle/python/testdata/simple_test_with_conftest/conftest.py index bbdfb4c588..41010956cf 100644 --- a/gazelle/python/testdata/simple_test_with_conftest/conftest.py +++ b/gazelle/python/testdata/simple_test_with_conftest/conftest.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/gazelle/python/testdata/simple_test_with_conftest/foo.py b/gazelle/python/testdata/simple_test_with_conftest/foo.py index 932de45b74..3f049df738 100644 --- a/gazelle/python/testdata/simple_test_with_conftest/foo.py +++ b/gazelle/python/testdata/simple_test_with_conftest/foo.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def foo(): return "foo" diff --git a/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py b/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py index bd0fe61faa..78d23482a7 100644 --- a/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py +++ b/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import foo.has_main.python.my_module \ No newline at end of file +import foo.has_main.python.my_module diff --git a/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py b/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py index 3c9ed1a1bd..ad77cb7dcb 100644 --- a/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py +++ b/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py @@ -13,4 +13,4 @@ # limitations under the License. # For test purposes only. -import foo.has_test.python.my_module \ No newline at end of file +import foo.has_test.python.my_module diff --git a/python/pip_install/tools/dependency_resolver/__init__.py b/python/pip_install/tools/dependency_resolver/__init__.py index bbdfb4c588..41010956cf 100644 --- a/python/pip_install/tools/dependency_resolver/__init__.py +++ b/python/pip_install/tools/dependency_resolver/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/python/pip_install/tools/dependency_resolver/dependency_resolver.py b/python/pip_install/tools/dependency_resolver/dependency_resolver.py index 5e914bc9e9..afe5076b4f 100644 --- a/python/pip_install/tools/dependency_resolver/dependency_resolver.py +++ b/python/pip_install/tools/dependency_resolver/dependency_resolver.py @@ -99,8 +99,10 @@ def main( bazel_runfiles = runfiles.Create() requirements_file = _select_golden_requirements_file( - requirements_txt=requirements_txt, requirements_linux=requirements_linux, - requirements_darwin=requirements_darwin, requirements_windows=requirements_windows + requirements_txt=requirements_txt, + requirements_linux=requirements_linux, + requirements_darwin=requirements_darwin, + requirements_windows=requirements_windows, ) resolved_requirements_in = _locate(bazel_runfiles, requirements_in) @@ -120,8 +122,8 @@ def main( # use the runfiles file first. Thus, we need to compute the relative path # from the execution root. # Note: Windows cannot reference generated files without runfiles support enabled. - requirements_in_relative = requirements_in[len(repository_prefix):] - requirements_file_relative = requirements_file[len(repository_prefix):] + requirements_in_relative = requirements_in[len(repository_prefix) :] + requirements_file_relative = requirements_file[len(repository_prefix) :] # Before loading click, set the locale for its parser. # If it leaks through to the system setting, it may fail: @@ -157,7 +159,9 @@ def main( os.environ["CUSTOM_COMPILE_COMMAND"] = update_command os.environ["PIP_CONFIG_FILE"] = os.getenv("PIP_CONFIG_FILE") or os.devnull - argv.append(f"--output-file={requirements_file_relative if UPDATE else requirements_out}") + argv.append( + f"--output-file={requirements_file_relative if UPDATE else requirements_out}" + ) argv.append( requirements_in_relative if Path(requirements_in_relative).exists() diff --git a/python/private/repack_whl.py b/python/private/repack_whl.py index ea9c01f76f..9052ac39c6 100644 --- a/python/private/repack_whl.py +++ b/python/private/repack_whl.py @@ -152,7 +152,9 @@ def main(sys_argv): record_contents = record_path.read_text() if record_path.exists() else "" distribution_prefix = distinfo_dir.with_suffix("").name - with _WhlFile(args.output, mode="w", distribution_prefix=distribution_prefix) as out: + with _WhlFile( + args.output, mode="w", distribution_prefix=distribution_prefix + ) as out: for p in _files_to_pack(patched_wheel_dir, record_contents): rel_path = p.relative_to(patched_wheel_dir) out.add_file(str(rel_path), p) diff --git a/tests/integration/ignore_root_user_error/bzlmod_test.py b/tests/integration/ignore_root_user_error/bzlmod_test.py index 62bc4f4695..98715b32ec 100644 --- a/tests/integration/ignore_root_user_error/bzlmod_test.py +++ b/tests/integration/ignore_root_user_error/bzlmod_test.py @@ -12,26 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest -import pathlib import json +import pathlib +import unittest from python.runfiles import runfiles + class BzlmodTest(unittest.TestCase): def test_toolchains(self): rf = runfiles.Create() - debug_path = pathlib.Path(rf.Rlocation( - "rules_python_bzlmod_debug/debug_info.json" - )) + debug_path = pathlib.Path( + rf.Rlocation("rules_python_bzlmod_debug/debug_info.json") + ) debug_info = json.loads(debug_path.read_bytes()) expected = [ - {'ignore_root_user_error': True, 'name': 'python_3_11', }, - {'ignore_root_user_error': True, 'name': 'python_3_10'} + {"ignore_root_user_error": True, "name": "python_3_11"}, + {"ignore_root_user_error": True, "name": "python_3_10"}, ] - self.assertCountEqual(debug_info["toolchains_registered"], - expected) + self.assertCountEqual(debug_info["toolchains_registered"], expected) + if __name__ == "__main__": unittest.main() diff --git a/tests/pycross/patched_py_wheel_library_test.py b/tests/pycross/patched_py_wheel_library_test.py index 4591187f57..e1b404a0ef 100644 --- a/tests/pycross/patched_py_wheel_library_test.py +++ b/tests/pycross/patched_py_wheel_library_test.py @@ -23,7 +23,9 @@ class TestPyWheelLibrary(unittest.TestCase): def setUp(self): self.extraction_dir = Path( - RUNFILES.Rlocation("rules_python/tests/pycross/patched_extracted_wheel_for_testing") + RUNFILES.Rlocation( + "rules_python/tests/pycross/patched_extracted_wheel_for_testing" + ) ) self.assertTrue(self.extraction_dir.exists(), self.extraction_dir) self.assertTrue(self.extraction_dir.is_dir(), self.extraction_dir)