1313# limitations under the License.
1414"""Main entry point for bazel_to_cmake."""
1515
16- # pylint: disable=relative-beyond-top-level
16+ # pylint: disable=relative-beyond-top-level,g-importing-member,missing-function-docstring
1717
1818import argparse
19+ from collections .abc import Iterable
1920import json
2021import os
2122import pathlib
2223import pickle
2324import sys
24- from typing import Dict , List , Set , Union
2525
2626from . import native_rules # pylint: disable=unused-import
2727from .active_repository import Repository
4444
4545def maybe_expand_special_targets (
4646 t : TargetId ,
47- available : Union [ Set [ TargetId ], List [ TargetId ] ],
48- ):
47+ available : Iterable [ TargetId ],
48+ ) -> list [ TargetId ] :
4949 # Handle special targets t, :all, :... from the available targets.
50- result : List [TargetId ] = []
50+ result : list [TargetId ] = []
5151 if t .target_name == "all" :
5252 for u in available :
5353 if u .package_id == t .package_id :
@@ -65,11 +65,11 @@ def maybe_expand_special_targets(
6565def get_bindings_from_args (
6666 args : argparse .Namespace ,
6767 repository_id : RepositoryId ,
68- ) -> Dict [TargetId , TargetId ]:
68+ ) -> dict [TargetId , TargetId ]:
6969 # Add repository bindings. These provide the "native.bind" equivalent,
7070 # and are resolved after repo mappings. Unlike native.bind, they are
7171 # not restricted to only bind //external:name = alias values.
72- bindings : Dict [TargetId , TargetId ] = {}
72+ bindings : dict [TargetId , TargetId ] = {}
7373 for name in args .bind :
7474 i = name .find ("=" )
7575 assert i > 0
@@ -85,7 +85,7 @@ def get_bindings_from_args(
8585def create_root_workspace (
8686 args : argparse .Namespace ,
8787 repository_id : RepositoryId ,
88- ):
88+ ) -> Workspace :
8989 """Creates a workspace for the root repository."""
9090 assert args .cmake_vars is not None
9191 try :
@@ -121,7 +121,7 @@ def create_root_workspace(
121121
122122def load_root_workspace (
123123 args : argparse .Namespace ,
124- ):
124+ ) -> Workspace :
125125 """Unpickles a workspace and loads the repository from it."""
126126 with open (args .load_workspace , "rb" ) as f :
127127 workspace = pickle .load (f )
@@ -139,7 +139,7 @@ def do_process_build_files(
139139 args : argparse .Namespace ,
140140 active_repo : Repository ,
141141 state : EvaluationState ,
142- ):
142+ ) -> set [ TargetId ] :
143143 # Load build files.
144144 include_packages = args .include_package or ["**" ]
145145 exclude_packages = args .exclude_package or []
@@ -185,7 +185,7 @@ def do_process_build_files(
185185 return targets_to_analyze
186186
187187
188- def run_main (args : argparse .Namespace ):
188+ def run_main (args : argparse .Namespace ) -> int :
189189 assert args .bazel_repo_name
190190 repository_id : RepositoryId = RepositoryId (args .bazel_repo_name )
191191
@@ -347,7 +347,7 @@ def _persist_cmakepairs(target: TargetId, cmake_pair: CMakeTargetPair):
347347 return 0
348348
349349
350- def main ():
350+ def main () -> int :
351351 ap = argparse .ArgumentParser ()
352352 # Used for sub-projects only.
353353 ap .add_argument ("--load-workspace" )
0 commit comments