Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
# limitations under the License.

---
buildifier:
# keep these arguments in sync with .pre-commit-config.yaml
# Use a specific version to avoid skew issues when new versions are released.
version: 6.1.0
warnings: "all"
# NOTE: Minimum supported version is 7.x
.minimum_supported_version: &minimum_supported_version
# For testing minimum supported version.
Expand Down
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
# To update these lines, execute
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,rules_python-repro,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,rules_python-repro,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/docs,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/another_module,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma,tests/modules/other/nspkg_single,tests/modules/other/simple_v1,tests/modules/other/simple_v2,tests/modules/other/with_external_data,tests/whl_with_build_files/testdata,tests/whl_with_build_files/testdata/somepkg,tests/whl_with_build_files/testdata/somepkg-1.0.dist-info,tests/whl_with_build_files/testdata/somepkg/subpkg

test --test_output=errors

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: lint

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

defaults:
run:
shell: bash

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.1
8 changes: 3 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@ repos:
hooks:
- id: buildifier
args: &args
# Keep this argument in sync with .bazelci/presubmit.yaml
- --warnings=all
- id: buildifier-lint
args: *args
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 6.0.1
hooks:
- id: isort
name: isort (python)
args:
- --profile
- black
args: ["--profile", "black", "--filter-files"]
exclude: import_nested_var/__init__.py
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ use_repo(pip, "rules_python_publish_deps")
bazel_dep(name = "stardoc", version = "0.7.2", repo_name = "io_bazel_stardoc")

# ===== DEV ONLY DEPS AND SETUP BELOW HERE =====
bazel_dep(name = "rules_bazel_integration_test", version = "0.27.0", dev_dependency = True)
bazel_dep(name = "rules_bazel_integration_test", version = "0.33.2", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
Expand Down
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@

# --- Extlinks configuration
extlinks = {
"gh-issue": (f"https://github.com/bazel-contrib/rules_python/issues/%s", "#%s issue"),
"gh-issue": (
f"https://github.com/bazel-contrib/rules_python/issues/%s",
"#%s issue",
),
"gh-path": (f"https://github.com/bazel-contrib/rules_python/tree/main/%s", "%s"),
"gh-pr": (f"https://github.com/bazel-contrib/rules_python/pulls/%s", "#%s PR"),
}
Expand Down
8 changes: 6 additions & 2 deletions examples/wheel/wheel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,9 @@ def test_extra_requires(self):
)

def test_requires_dist_depends_on_extras(self):
filename = self._get_path("requires_dist_depends_on_extras-0.0.1-py3-none-any.whl")
filename = self._get_path(
"requires_dist_depends_on_extras-0.0.1-py3-none-any.whl"
)

with zipfile.ZipFile(filename) as zf:
self.assertAllEntriesHasReproducibleMetadata(zf)
Expand All @@ -591,7 +593,9 @@ def test_requires_dist_depends_on_extras(self):
)

def test_requires_dist_depends_on_extras_file(self):
filename = self._get_path("requires_dist_depends_on_extras_using_file-0.0.1-py3-none-any.whl")
filename = self._get_path(
"requires_dist_depends_on_extras_using_file-0.0.1-py3-none-any.whl"
)

with zipfile.ZipFile(filename) as zf:
self.assertAllEntriesHasReproducibleMetadata(zf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

# Ensure that even though @gazelle_python_test//other_pip_dep provides "third_party",
# we can still override "third_party.foo.bar"
import third_party.foo.bar
import third_party.foo.bar # isort:skip

import third_party
from third_party import baz
import third_party # isort:skip
from third_party import baz # isort:skip

_ = sys
_ = bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# fmt: off

# baz is a variable in foo/bar/baz.py
from foo\
.bar.\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

def some_init():
return "some_init"
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

def some_function():
return "some_function"
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from ...my_library import (
from ...my_library import ( # Import path should be package1.my_library.some_function
some_function,
) # Import path should be package1.my_library.some_function
from ...my_library.foo import (
)
from ...my_library.foo import ( # Import path should be package1.my_library.foo.some_function
some_function,
) # Import path should be package1.my_library.foo.some_function
from .library import (
other_module,
) # Import path should be package1.subpackage1.subpackage2.library.other_module
from .. import some_module # Import path should be package1.subpackage1.some_module
)
from .. import some_function # Import path should be package1.subpackage1.some_function
from .. import some_module # Import path should be package1.subpackage1.some_module
from .library import ( # Import path should be package1.subpackage1.subpackage2.library.other_module
other_module,
)
5 changes: 1 addition & 4 deletions python/bin/repl_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ def complete(self, text, state):
elif "GNU readline" in readline.__doc__: # type: ignore
readline.parse_and_bind("tab: complete")
else:
print(
"Could not enable tab completion: "
"unable to determine readline backend"
)
print("Could not enable tab completion: unable to determine readline backend")
except ImportError:
print(
"Could not enable tab completion: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def main(
# Further, shutil.copy preserves the source file's mode, and so if
# our source file is read-only (the default under Perforce Helix),
# this scratch file will also be read-only, defeating its purpose.
with open(resolved_requirements_file, "rb") as fsrc, open(requirements_out, "wb") as fdst:
with open(resolved_requirements_file, "rb") as fsrc, open(
requirements_out, "wb"
) as fdst:
shutil.copyfileobj(fsrc, fdst)

update_command = (
Expand Down
2 changes: 1 addition & 1 deletion python/private/stage2_bootstrap_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_windows_path_with_unc_prefix(path):
break
except (ValueError, KeyError):
pass
if win32_version and win32_version >= '10.0.14393':
if win32_version and win32_version >= "10.0.14393":
return path

# import sysconfig only now to maintain python 2.6 compatibility
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/local_toolchains/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def test_python_from_path_used(self):
# runs e.g. /usr/bin/python3
with tempfile.TemporaryDirectory() as temp_dir:
file_path = os.path.join(temp_dir, "info.py")
with open(file_path, 'w') as f:
with open(file_path, "w") as f:
f.write(
"""
"""
import sys
print(sys.executable)
print(sys._base_executable)
Expand Down