Skip to content

Commit 4012d3d

Browse files
committed
Remove Pytype integration
See google/pytype#1925.
1 parent 7a1a587 commit 4012d3d

File tree

9 files changed

+11
-383
lines changed

9 files changed

+11
-383
lines changed

.bazelrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ build:windows --copt='/external:W0' --host_copt='/external:W0'
2929
# Run Pylint by default.
3030
build --aspects='//dev:pylint.bzl%pylint'
3131

32-
# Run Pytype on platforms where it’s supported.
33-
build:linux --aspects='//dev:pytype.bzl%pytype'
34-
build:macos --aspects='//dev:pytype.bzl%pytype'
35-
3632
# Run Mypy by default.
3733
build --aspects='//dev:mypy.bzl%mypy'
3834
build --output_groups='+mypy'

dev/BUILD

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ compile_pip_requirements(
5959
requirements_in = "requirements.txt",
6060
requirements_txt = ":requirements_lock",
6161
tags = [
62-
# Don’t try to run Pylint, Pytype, or Mypy. This target doesn’t contain
63-
# any of our source files.
62+
# Don’t try to run Pylint or Mypy. This target doesn’t contain any of
63+
# our source files.
6464
"no-pylint",
65-
"no-pytype",
6665
"no-mypy",
6766
],
6867
)
@@ -82,13 +81,7 @@ py_binary(
8281
main = "check_python.py",
8382
python_version = "3.12",
8483
visibility = ["//private:__pkg__"],
85-
deps = [requirement("pylint")] + select({
86-
# Pytype doesn’t work on Windows, so don’t build it when running
87-
# “bazel build //...”.
88-
"@platforms//os:linux": [requirement("pytype")],
89-
"@platforms//os:macos": [requirement("pytype")],
90-
"//conditions:default": [],
91-
}),
84+
deps = [requirement("pylint")],
9285
)
9386

9487
nogo(
@@ -135,15 +128,6 @@ bzl_library(
135128
],
136129
)
137130

138-
bzl_library(
139-
name = "pytype",
140-
srcs = ["pytype.bzl"],
141-
deps = [
142-
":check_python_bzl",
143-
"@rules_python//python:py_info_bzl",
144-
],
145-
)
146-
147131
# keep
148132
bzl_library(
149133
name = "check_python_bzl",

dev/check_python.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def check_python(
2626
additional_inputs = [],
2727
mnemonic,
2828
progress_message):
29-
"""Run Pylint or Pytype on Python source files.
29+
"""Run Pylint on Python source files.
3030
3131
Args:
3232
ctx: the rule context
3333
info: a PyInfo object
3434
stem: base name of files that will be generated
35-
program: name of the program to run, either "pylint" or "pytype"
35+
program: name of the program to run, must be "pylint"
3636
program_args: additional arguments for the program, either an Args object
3737
or None
3838
additional_inputs: list of additional input files for the program,

dev/check_python.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Runs Pylint and Pytype."""
15+
"""Runs Pylint."""
1616

1717
import argparse
1818
import json
1919
import os
2020
import os.path
2121
import pathlib
22-
import platform
2322
import shutil
2423
import sys
2524
import subprocess
@@ -37,16 +36,15 @@ def main() -> None:
3736
subparsers = parser.add_subparsers(required=True, dest='program')
3837
pylint = subparsers.add_parser('pylint', allow_abbrev=False)
3938
pylint.add_argument('--pylintrc', type=pathlib.Path, required=True)
40-
subparsers.add_parser('pytype', allow_abbrev=False)
4139
args = parser.parse_args()
4240
workspace_name = args.workspace_name
4341
dirs = [d for d in sys.path if os.path.basename(d) == workspace_name]
4442
if len(dirs) != 1:
4543
raise ValueError(f'no unique workspace directory: {dirs}')
4644
module_space = pathlib.Path(dirs[0]).parent
4745
module_space_stat = module_space.stat()
48-
# Set a fake PYTHONPATH so that Pylint and Pytype can find imports for the
49-
# main and external repositories.
46+
# Set a fake PYTHONPATH so that Pylint can find imports for the main and
47+
# external repositories.
5048
params = json.loads(args.params.read_text(encoding='utf-8'))
5149
srcs = []
5250
tempdir = pathlib.Path(tempfile.mkdtemp(prefix='pylint-'))
@@ -67,11 +65,6 @@ def main() -> None:
6765
(path / '__init__.py').touch()
6866
srcset = frozenset(srcs)
6967
repository_path = [str(tempdir / d) for d in args.path]
70-
# Pytype wants a Python binary available under the name “python”. See the
71-
# function pytype.tools.environment.check_python_exe_or_die.
72-
bindir = tempdir / 'bin'
73-
bindir.mkdir()
74-
(bindir / 'python').symlink_to(sys.executable)
7568
orig_path = []
7669
for entry in sys.path:
7770
try:
@@ -87,7 +80,6 @@ def main() -> None:
8780
pass # ignore nonexisting entries
8881
cwd = tempdir / workspace_name
8982
env = dict(os.environ,
90-
PATH=os.pathsep.join([str(bindir)] + os.get_exec_path()),
9183
PYTHONPATH=os.pathsep.join(orig_path + repository_path))
9284
if args.program == 'pylint':
9385
result = subprocess.run(
@@ -102,18 +94,6 @@ def main() -> None:
10294
if result.returncode:
10395
print(result.stdout)
10496
sys.exit(result.returncode)
105-
if platform.system() != 'Windows' and args.program == 'pytype':
106-
result = subprocess.run(
107-
[sys.executable, '-m', 'pytype',
108-
'--pythonpath=' + os.pathsep.join(repository_path),
109-
'--no-cache', '--'] + [str(file.relative_to(cwd))
110-
for file in sorted(srcset)],
111-
check=False, cwd=cwd, env=env,
112-
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
113-
encoding='utf-8', errors='backslashreplace')
114-
if result.returncode:
115-
print(result.stdout)
116-
sys.exit(result.returncode)
11797
# Only clean up the workspace if we exited successfully, to help with
11898
# debugging.
11999
shutil.rmtree(tempdir)

dev/pytype.bzl

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)