This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lucatrv
Recipients lucatrv, paul.j3, rhettinger
Date 2020-03-02.23:33:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583192002.84.0.926921679158.issue39809@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2020-03-02 23:33:22lucatrvsetrecipients: + lucatrv, rhettinger, paul.j3
2020-03-02 23:33:22lucatrvsetmessageid: <1583192002.84.0.926921679158.issue39809@roundup.psfhosted.org>
2020-03-02 23:33:22lucatrvlinkissue39809 messages
2020-03-02 23:33:22lucatrvcreate