Skip to content

feat: expose a function's module-level aliases to project plugins - #192

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
feat/function-aliases-api
Sep 29, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
feat/function-aliases-api

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

ModuleFunction.aliases gives a project plugin the module-level names bound to a function by assigning one name to another (main = actual), transitively and in source order; a method or a nested function has none.

Since 0.18.0 an EntryPoint may name a project function by its own symbol, and the engine now applies it through a module-level alias of the function (#188). An integration declaring a handler by the name a module binds, handlers.main, could not tell whether that name reached a function: a name bound to a call or an import names nothing, silently. With aliases the plugin checks that the declared name is a function's own name or one of its aliases, and reports the rest as unresolved; it grows no Python resolver of its own, the identity of the callable stays with the engine.

  • ModuleFunction gains aliases: tuple[str, ...] = (), computed in EntryPointAnalysis with the same _aliases walk the entry-point matching uses, so both agree by construction.
  • The cache encodes the aliases; CACHE_FORMAT becomes 11, so an older cache is rebuilt rather than read without them.
  • docs/plugins.md and the CHANGELOG describe the field.

Tests: tests/test_function_aliases_api.py (2 cases, failing before the change: the names a module binds to each function, none for a method, a nested function or a name bound to a call, and the aliases surviving the cache); pytest -m "not regression" 1535 passed, 2 skipped; regression corpus 19 passed under Python 3.12, the interpreter the snapshots were recorded with (under 3.14, backend/app/api/deps.py of full-stack-fastapi-template parses and the snapshot's syntax-error disappears, unrelated to this change); ruff check . and mypy clean.

ModuleFunction.aliases lists the module-level names bound to a function by assigning one name to another, transitively and in source order, computed with the walk the entry-point matching uses so both agree. An integration declaring a handler by the name a module binds can then report a name the engine resolves to no function. The cache encodes the aliases and its format becomes 11.
@SizzleUnrlsd SizzleUnrlsd added the enhancement New feature or request label Sep 29, 2026
@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 29, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit 85406b1 into main Sep 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant