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, 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
|
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.
Source code in src/lcp/scanner.py
ScannedModule
dataclass
¶
scan_module ¶
scan_module(module: ModuleType, include_private: bool = False, _visited: set | None = None, _package_root: str | None = None) -> list[ScannedSymbol]
Scan a module for symbols.
Source code in src/lcp/scanner.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
scan_package ¶
scan_package(package_name: str, include_private: bool = False, recursive: bool = True) -> ScannedModule
Scan an installed package and return scanned information.