Skip to content

Commit ff14dbb

Browse files
authored
ci: Exclude samtranslator.internal from interface scan (#3027)
1 parent ce02bf3 commit ff14dbb

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

bin/public_interface.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@
1515
import pkgutil
1616
import sys
1717
from pathlib import Path
18-
from typing import Any, Dict, List, NamedTuple, Set, Union
18+
from typing import Any, Dict, List, NamedTuple, Optional, Set, Union
1919

2020
_ARGUMENT_SELF = {"kind": "POSITIONAL_OR_KEYWORD", "name": "self"}
2121

2222

2323
class InterfaceScanner:
24-
def __init__(self) -> None:
24+
def __init__(self, skipped_modules: Optional[List[str]] = None) -> None:
2525
self.signatures: Dict[str, Union[inspect.Signature]] = {}
2626
self.variables: Set[str] = set()
27+
self.skipped_modules: Set[str] = set(skipped_modules or [])
2728

2829
def scan_interfaces_recursively(self, module_name: str) -> None:
30+
if module_name in self.skipped_modules:
31+
return
2932
self._scan_interfaces_in_module(module_name)
3033
for submodule in pkgutil.iter_modules([module_name.replace(".", os.path.sep)]):
3134
submodule_name = module_name + "." + submodule.name
@@ -212,13 +215,20 @@ def main() -> None:
212215
subparsers = parser.add_subparsers(dest="command")
213216
extract = subparsers.add_parser("extract", help="Extract public interfaces")
214217
extract.add_argument("--module", help="The module to extract public interfaces", type=str, default="samtranslator")
218+
extract.add_argument(
219+
"--skipped-module",
220+
help="The modules that should be skipped",
221+
type=str,
222+
nargs="*",
223+
default=["samtranslator.internal"],
224+
)
215225
check = subparsers.add_parser("check", help="Check public interface changes")
216226
check.add_argument("original_json", help="The original public interface JSON file", type=Path)
217227
check.add_argument("new_json", help="The new public interface JSON file", type=Path)
218228
args = parser.parse_args()
219229

220230
if args.command == "extract":
221-
scanner = InterfaceScanner()
231+
scanner = InterfaceScanner(skipped_modules=args.skipped_module)
222232
scanner.scan_interfaces_recursively(args.module)
223233
_print(scanner.signatures, scanner.variables)
224234
elif args.command == "check":

0 commit comments

Comments
 (0)