Repository navigation
feat: expose a function's module-level aliases to project plugins - #192
Merged
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ModuleFunction.aliasesgives 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
EntryPointmay 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. Withaliasesthe 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.ModuleFunctiongainsaliases: tuple[str, ...] = (), computed inEntryPointAnalysiswith the same_aliaseswalk the entry-point matching uses, so both agree by construction.CACHE_FORMATbecomes 11, so an older cache is rebuilt rather than read without them.docs/plugins.mdand 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.pyof full-stack-fastapi-template parses and the snapshot'ssyntax-errordisappears, unrelated to this change);ruff check .andmypyclean.