Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/run_mypy.py
3987 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
19
"""Run mypy type checker for Selenium Python bindings.
20
21
This script is used by Bazel to run mypy type checking.
22
"""
23
24
import os
25
import sys
26
27
from mypy import api
28
29
30
def main():
31
# Find the workspace root - Bazel sets BUILD_WORKSPACE_DIRECTORY when using 'bazel run'
32
workspace = os.environ.get("BUILD_WORKSPACE_DIRECTORY")
33
if workspace:
34
py_dir = os.path.join(workspace, "py")
35
else:
36
# Fallback for direct execution
37
py_dir = os.path.dirname(os.path.abspath(__file__))
38
39
os.chdir(py_dir)
40
41
# Run mypy on the selenium package
42
# Configuration is read from pyproject.toml [tool.mypy] section
43
args = ["selenium", *sys.argv[1:]]
44
stdout, stderr, exit_code = api.run(args)
45
46
if stdout:
47
print(stdout, end="")
48
if stderr:
49
print(stderr, end="", file=sys.stderr)
50
51
sys.exit(exit_code)
52
53
54
if __name__ == "__main__":
55
main()
56
57