Skip to content

Commit e3b9858

Browse files
committed
pre-commit: fix issues reported by ruff-check
1 parent 58190f7 commit e3b9858

20 files changed

Lines changed: 30 additions & 43 deletions

File tree

examples/bzlmod/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_coverage_sys_path(self):
5858
f"sys.path has {len(sys.path)} items:\n {all_paths}",
5959
)
6060

61-
first_item, last_item = sys.path[0], sys.path[-1]
61+
first_item = sys.path[0]
6262
self.assertFalse(
6363
first_item.endswith("coverage"),
6464
f"Expected the first item in sys.path '{first_item}' to not be related to coverage",

examples/wheel/wheel_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ def test_minimal_data_files(self):
523523

524524
with zipfile.ZipFile(filename) as zf:
525525
self.assertAllEntriesHasReproducibleMetadata(zf)
526-
metadata_file = None
527526
self.assertEqual(
528527
zf.namelist(),
529528
[

python/bin/repl_stub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
The logic for PYTHONSTARTUP is handled in python/private/repl_template.py.
1414
"""
1515

16-
# Capture the globals from PYTHONSTARTUP so we can pass them on to the console.
17-
console_locals = globals().copy()
18-
1916
import code
2017
import rlcompleter
2118
import sys
2219

20+
# Capture the globals from PYTHONSTARTUP so we can pass them on to the console.
21+
console_locals = globals().copy()
22+
2323

2424
class DynamicCompleter(rlcompleter.Completer):
2525
"""

python/private/py_console_script_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class EntryPointsParser(configparser.ConfigParser):
7272
optionxform = staticmethod(str)
7373

7474

75-
def _guess_entry_point(guess: str, console_scripts: dict[string, string]) -> str | None:
75+
def _guess_entry_point(guess: str, console_scripts: dict[str, str]) -> str | None:
7676
for key, candidate in console_scripts.items():
7777
if guess == key:
7878
return candidate
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# __path__ manipulation added by bazel-contrib/rules_python to support namespace pkgs.
2-
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
2+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # noqa: F821

python/private/site_init_template.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ def _setup_sys_path():
131131
"""Perform Bazel/binary specific sys.path setup."""
132132
_print_verbose("site init: initial sys.path:\n", "\n".join(sys.path))
133133
seen = set(sys.path)
134-
python_path_entries = []
135-
136134
def _maybe_add_path(path, reason):
137135
if path in seen:
138136
return

python/private/stage2_bootstrap_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def get_windows_path_with_unc_prefix(path):
131131
return path
132132

133133
# Lets start the unicode fun
134+
unicode_prefix = "\\\\?\\"
134135
if path.startswith(unicode_prefix):
135136
return path
136137

python/private/zipapp/zip_main_template.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515
# for the program and may be skipped entirely; the self-executable zip
1616
# preamble may jump directly to the stage2 bootstrap.
1717

18-
import sys
19-
20-
# The Python interpreter unconditionally prepends the directory containing this
21-
# script (following symlinks) to the import path. This is the cause of #9239,
22-
# and is a special case of #7091. We therefore explicitly delete that entry.
23-
# TODO(#7091): Remove this hack when no longer necessary.
24-
del sys.path[0]
25-
2618
import os
2719
import shutil
2820
import stat
2921
import subprocess
22+
import sys
3023
import tempfile
3124
import zipfile
3225
from os.path import basename, dirname, join, normpath
3326

27+
# The Python interpreter unconditionally prepends the directory containing this
28+
# script (following symlinks) to the import path. This is the cause of #9239,
29+
# and is a special case of #7091. We therefore explicitly delete that entry.
30+
# TODO(#7091): Remove this hack when no longer necessary.
31+
del sys.path[0]
32+
3433
# runfiles-root-relative path
3534
_STAGE2_BOOTSTRAP = "%stage2_bootstrap%"
3635
# runfiles-root-relative path to venv's bin/python3. Empty if venv not being used.

python/runfiles/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from .runfiles import *
15+
from .runfiles import Create as Create, CreateDirectoryBased as CreateDirectoryBased, CreateManifestBased as CreateManifestBased, Path as Path, Runfiles as Runfiles # noqa: F401

sphinxdocs/sphinxdocs/private/sphinx_server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class DirectoryHandler(server.SimpleHTTPRequestHandler):
1919
def __init__(self, *args, **kwargs):
2020
super().__init__(directory=serve_directory, *args, **kwargs)
2121

22-
address = ("0.0.0.0", 8000)
2322
# with server.ThreadingHTTPServer(address, DirectoryHandler) as (ip, port, httpd):
2423
with _start_server(DirectoryHandler, "0.0.0.0", 8000) as (ip, port, httpd):
2524

0 commit comments

Comments
 (0)