Scanner¶
The top-level scan() entry point runs the full scan → generate → validate pipeline in a single call.
lcp.scan ¶
scan(package_name: str, *, include_private: bool = False, recursive: bool = True, include_tests: bool = False, validate: bool = True) -> LCPDocument
Scan a Python package and generate an LCP document.
This is the main entry point for the SDK.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_name
|
str
|
The name of an installed Python package to scan. |
required |
include_private
|
bool
|
Include private symbols (starting with _). |
False
|
recursive
|
bool
|
Scan submodules recursively. |
True
|
include_tests
|
bool
|
When |
False
|
validate
|
bool
|
Validate the output against the LCP schema. |
True
|
Returns:
| Type | Description |
|---|---|
LCPDocument
|
An LCPDocument containing the scanned library information. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the package cannot be imported. |
LCPValidationError
|
If validation is enabled and the output is invalid. |
Example
from lcp import scan doc = scan("json") doc.to_file("json.lcp.json")
Source code in src/lcp/__init__.py
lcp.scanner ¶
Scanner module for introspecting Python packages.
ScannedParam
dataclass
¶
Scanned parameter information.
Source code in src/lcp/scanner.py
ScannedSignature
dataclass
¶
Scanned function/method signature.
Source code in src/lcp/scanner.py
ScannedSymbol
dataclass
¶
Scanned symbol information.
aliases holds (module_path, name) pairs where the symbol is
re-exported inside its own package (e.g. ("requests", "get") for a
function defined in requests.api); the definition site stays the
canonical identity.
Source code in src/lcp/scanner.py
ScannedModule
dataclass
¶
Scanned module information.
Source code in src/lcp/scanner.py
scanned_to_dict ¶
Serialize a :class:ScannedModule tree into a JSON-safe dict.
Total by construction: complex parameter defaults degrade to a marker rather than raising, so the child can always emit a document.
Source code in src/lcp/scanner.py
scanned_from_dict ¶
Rebuild a :class:ScannedModule tree from :func:scanned_to_dict output.
Source code in src/lcp/scanner.py
scan_module ¶
scan_module(module: ModuleType, include_private: bool = False, _visited: set | None = None, _package_root: str | None = None, _alias_records: list[_AliasRecord] | None = None, _followable_tops: frozenset[str] | None = None) -> list[ScannedSymbol]
Scan a module for symbols.
Source code in src/lcp/scanner.py
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 | |
scan_package ¶
scan_package(package_name: str, include_private: bool = False, recursive: bool = True, include_tests: bool = False) -> ScannedModule
Scan an installed package and return scanned information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_name
|
str
|
Import path of the package to scan. |
required |
include_private
|
bool
|
Include private symbols (names starting with |
False
|
recursive
|
bool
|
Walk submodules recursively. |
True
|
include_tests
|
bool
|
When |
False
|
Source code in src/lcp/scanner.py
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 | |