MCPcopy Index your code
hub / github.com/numpy/numpy / main

Function main

tools/ci/check_c_api_usage.py:121–260  ·  view source on GitHub ↗
(argv: list[str] | None = None)

Source from the content-addressed store, hash-verified

119
120
121def main(argv: list[str] | None = None) -> int:
122 # List of suspicious function calls:
123 suspicious_funcs: tuple[str, ...] = (
124 "PyList_GetItem",
125 "PyDict_GetItem",
126 "PyDict_GetItemWithError",
127 "PyDict_GetItemString",
128 "PyDict_SetDefault",
129 "PyDict_Next",
130 "PyWeakref_GetObject",
131 "PyWeakref_GET_OBJECT",
132 "PyList_GET_ITEM",
133 "_PyDict_GetItemStringWithError",
134 "PySequence_Fast"
135 )
136 func_rx = build_func_rx(suspicious_funcs)
137 noqa_markers = (
138 "noqa: borrowed-ref OK",
139 "noqa: borrowed-ref - manual fix needed"
140 )
141 default_exts = {".c", ".h", ".c.src", ".cpp"}
142 default_excludes = {"pythoncapi-compat"}
143
144 ap = argparse.ArgumentParser(description="Borrow-ref C API linter (Python).")
145 ap.add_argument(
146 "--quiet",
147 action="store_true",
148 help="Suppress normal output; exit status alone indicates result (useful\
149 for CI).",
150 )
151 ap.add_argument(
152 "-j", "--jobs",
153 type=int,
154 default=0,
155 help="Number of worker threads (0=auto, 1=sequential).",
156 )
157 ap.add_argument(
158 "--root",
159 default="numpy",
160 type=str,
161 help="Root directory to scan (default: numpy)"
162 )
163 ap.add_argument(
164 "--ext",
165 action="append",
166 default=None,
167 help=f"File extension(s) to include (repeatable). Defaults to {default_exts}",
168 )
169 ap.add_argument(
170 "--exclude",
171 action="append",
172 default=None,
173 help=f"Directory name(s) to exclude (repeatable). Default: {default_excludes}",
174 )
175 args = ap.parse_args(argv)
176
177 if args.ext:
178 exts = {e if e.startswith(".") else f".{e}" for e in args.ext}

Callers 1

Calls 12

build_func_rxFunction · 0.85
iter_source_filesFunction · 0.85
scan_fileFunction · 0.85
startswithMethod · 0.80
seekMethod · 0.80
minFunction · 0.50
maxFunction · 0.50
existsMethod · 0.45
sortMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…