Luca <luca...@hotmail.com> added the comment:

For the benefit of other developers willing to control text width with 
`argparse`, using the lambda function let `mypy` fail with the following error:

541: error: Argument "formatter_class" to "ArgumentParser" has incompatible 
type "Callable[[Any], RawDescriptionHelpFormatter]"; expected 
"Type[HelpFormatter]"

So I am reverting back to the following custom formatting class:

class 
RawDescriptionHelpFormatterMaxTextWidth80(argparse.RawDescriptionHelpFormatter):
        """Set maximum text width = 80."""

        def __init__(self, prog):
            width = min(80, shutil.get_terminal_size().columns - 2)
            argparse.RawDescriptionHelpFormatter.__init__(self, prog, 
width=width)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39809>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to