Add lambda support for CommandLineNode.commandLine#3015
Draft
Add lambda support for CommandLineNode.commandLine#3015
CommandLineNode.commandLine#3015Conversation
Co-authored-by: fabiencastan <153585+fabiencastan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for lambda evaluation in commandLine
Add lambda support for Feb 24, 2026
CommandLineNode.commandLine
| cmdSuffix = " " + self.commandLineRange.format(**chunk.range.toDict()) + " " + cmdSuffix | ||
|
|
||
| return cmdPrefix + chunk.node.nodeDesc.commandLine.format(**chunk.node._expVars, **chunk.node._staticExpVars, **cmdLineVars) + cmdSuffix | ||
| commandLineValue = getattr_static(self, 'commandLine') |
Member
There was a problem hiding this comment.
Suggested change
| commandLineValue = getattr_static(self, 'commandLine') | |
| # In the case of a lambda, we want a single "node" argument and not the node descriptor "self". | |
| # Therefore, we use getattr_static to retrieve the raw lambda instead of a bound method, which | |
| # would impose "self" as the first argument if we accessed "self.commandLine". | |
| commandLineValue = getattr_static(self, 'commandLine') |
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.
CommandLineNode.commandLineonly supported string templates formatted with.format(**vars). This adds support for it to also be a callable (lambda/function) taking anodeargument, evaluated at build time instead.Description
Users can now define
commandLineas a lambda receiving the node, enabling dynamic command line construction based on node state:Features list
CommandLineNode.commandLineaccepts a callable(node) -> strin addition to a string template.Implementation remarks
When a lambda is assigned as a class variable, Python's descriptor protocol wraps it as a bound method on instance access — passing
self(the node descriptor) as the first argument, notnode.inspect.getattr_staticbypasses this, retrieving the raw callable so it can be invoked with justchunk.node.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.