Skip to content

inherit ActionConfigFile from _AppendAction for better compatible with shtab #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tshu-w opened this issue Feb 25, 2022 · 2 comments
Closed
Labels
wontfix This will not be worked on

Comments

@tshu-w
Copy link
Contributor

tshu-w commented Feb 25, 2022

I open a new issue to discuss it and close the original one #108.

shtab use option type to decide completion nargs format in this line, however ActionConfigFile doesn't inherit from any of OPTION_MULTI = _AppendAction, _AppendConstAction, _CountAction, should ActionConfigFile inherit from _AppendAction as it accept python cli.py --config config.yaml --confg config2.yaml?

@tshu-w tshu-w changed the title inherit ActionConfigFile from _AppendAction for better compatible with inherit ActionConfigFile from _AppendAction for better compatible with shtab Feb 25, 2022
@mauvilsa mauvilsa added the enhancement New feature or request label Feb 28, 2022
@mauvilsa
Copy link
Member

mauvilsa commented Mar 1, 2022

ActionConfigFile inheriting from _AppendAction would only make sense if somehow it could use part of that class's functionality, e.g. doing super().__init__(...) or super().__call__(...). But there is nothing that can be reused from that class. Adding it just so that shtab handles it in some particular way would be a hack and not a good programing practice. Therefore, I will not do this.

@tshu-w you have suggested doing this but gave no motivation for it. What does it do?

Something that wouldn't be a hack and potential addition in jsonargparse could be:

import shtab
from jsonargparse import ActionConfigFile
shtab.OPTION_MULTI = shtab.OPTION_MULTI + (ActionConfigFile,)

Though, I don't know if OPTION_MULTI can be considered stable and part of the public API of shtab. Would be better to have an explicit public function to register such things. @casperdcl a comment from you could be useful.

@tshu-w
Copy link
Contributor Author

tshu-w commented Mar 1, 2022

Adding it just so that shtab handles it in some particular way would be a hack and not a good programing practice. Therefore, I will not do this.

Thanks for you reply. I see.

@tshu-w you have suggested doing this but gave no motivation for it. What does it do?

I don't particularly understand what you mean. If I understand correctly, the reason I did this was so that shtab would generate the correct zsh completion function for LightningCLI, since --config takes multiple arguments, but now zsh no longer completes --config after entering it once.

Anyway I understand your idea, and also implemented it like the following way.

import shtab
from jsonargparse import ActionConfigFile
shtab.OPTION_MULTI = shtab.OPTION_MULTI + (ActionConfigFile,)

I don't think this is something jsonargparse needs to handle anymore, so I closed the issue and will talk to @casperdcl about OPTION_MULTI if needed.

@tshu-w tshu-w closed this as completed Mar 1, 2022
@mauvilsa mauvilsa added wontfix This will not be worked on and removed enhancement New feature or request labels Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants