can't set context_settings with chain=true
See original GitHub issue@click.group(chain=True)
cannot be combined with @click.command(context_settings=CONTEXT_SETTINGS)
.
Expected Behavior
I should see Error: No such command "test".
Suppose we name the following script debug
, and we invoke using debug test
. This works:
#!/usr/bin/env python
import click
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.group(chain=True)
@click.pass_context
@click.command(context_settings=CONTEXT_SETTINGS)
def main(ctx):
print("hi")
if __name__ == '__main__':
main()
Also works:
#!/usr/bin/env python
import click
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.group()
@click.command(context_settings=CONTEXT_SETTINGS)
def main():
print("hi")
if __name__ == '__main__':
main()
Actual Behavior
Both, however, fail if we instead do @click.group(chain=True)
. The error messages are confusing. In case (1): TypeError: 'Context' object is not iterable
. For (2): TypeError: Attempted to convert a callback into a command twice.
Environment
- Python version: 3.7
- Click version: 7.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
sf::ContextSettings Class Reference (SFML / Learn / 2.5.1 ...
ContextSettings allows to define several advanced settings of the OpenGL context attached to a window.
Read more >Unit testing Spring Boot service layer bean which uses ...
It is a simple and fast way to unit test a class that uses method validation. First, create a proxy of the class...
Read more >Monster Component in Java with Spring | grison.me
We could add some spring projects like spring-hateoas to it in order to ... Boot application @Accessors(chain = true) // getters/setters are ...
Read more >click documentation - Read the Docs
Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary.
Read more >https://gitee.com/baomidou/mybatis-plus/pulls/97.patch
orElseThrow(() -> ExceptionUtils.mpe("can't find the logicFiled from table {%s}", ... Table table) { + //cannot add table alias for customized tenantId ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think you’re getting that error message because you’re decorating your
main
function with@click.group
and@click.command
, which AFAIK is not legal?If I create separate functions for the group and the command it seems to work as expected:
use:
We’re no longer planning to remove chain, so no worries about that at least.