Conversation
|
Core |
There was a problem hiding this comment.
The word Operation seems redundant to me and makes the functionality difficult to understand. BaseCommand should suffice in my opinion.
There was a problem hiding this comment.
In my opinion, decorators like these are too intrusive. They extract information from Azure CLI dynamically during runtime.
If I were you, I would statically parse source code files like _params.py with regex or string operation.
There was a problem hiding this comment.
I agree and like this refactoring. The original code is obviously abusing closure and makes the code difficult to read. #Resolved
There was a problem hiding this comment.
But still, even in closure, the values can be retrieved using inspect.getclosurevars(func). #WontFix
There was a problem hiding this comment.
The outer function name can be retrieved using __qualname__ following PEP 3155:
import inspect
def get_printer(msg):
def printer():
print(msg)
return printer
p = get_printer("Hello")
print(p.__qualname__)
print(inspect.getclosurevars(p))Output:
get_printer.<locals>.printer
ClosureVars(nonlocals={'msg': 'Hello'}, globals={}, builtins={'print': <built-in function print>}, unbound=set())
This can eliminate the necessity of these decorators.
There was a problem hiding this comment.
Thanks for your advice. This is a good solution to retrieve data from outer function. But I still prefer decorators because them build a layer between command definitions and linked functions in architecture level, which can not only solve questions above but also bring more flexibility.
fbac6aa to
c7cb205
Compare
fbda11b to
ac2e4dc
Compare
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
ac2e4dc to
a008d20
Compare
a008d20 to
bcf4148
Compare
|
Break down to small PRs: |
Description
This PR is for configurable CLI supporting. The core are modified in the following tree aspects:
Reconstruction AzCommandGroup
add_cli_commandfunction in AzCommandsLoader, which supports to register a command in command table by CommandOperation. Reduce the usage of_cli_commandfucntion.default_command_handlerdefault_arguments_loaderanddefault_description_loaderin_cli_commandbyCommandOperation_cli_generic_update_commandbyGenericUpdateCommandOperation_cli_wait_commandbyWaitCommandOperation_cli_show_commandbyShowCommandOperationPlaceholder Decorators
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.