Skip to content

Commit

Permalink
cli: Fix docstring processing with Python 3.13+
Browse files Browse the repository at this point in the history
Fix docstring processing code to reindent the docstrings if using Python
3.13 or newer.  Starting with this version, all docstrings are
automatically dedented by Python, which causes the regular expression to
fail to match.

Fixes tqdm#1585
  • Loading branch information
mgorny authored and casperdcl committed Aug 3, 2024
1 parent 448946a commit 5ba6595
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tqdm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import re
import sys
import textwrap
from ast import literal_eval as numeric

from .std import TqdmKeyError, TqdmTypeError, tqdm
Expand Down Expand Up @@ -177,7 +178,11 @@ def main(fp=sys.stderr, argv=None):
logging.basicConfig(level=getattr(logging, logLevel),
format="%(levelname)s:%(module)s:%(lineno)d:%(message)s")

d = tqdm.__doc__ + CLI_EXTRA_DOC
d = tqdm.__doc__
if sys.version_info >= (3, 13):
# Python 3.13+ automatically dedents docstrings
d = textwrap.indent(d, " ")
d += CLI_EXTRA_DOC

opt_types = dict(RE_OPTS.findall(d))
# opt_types['delim'] = 'chr'
Expand Down

0 comments on commit 5ba6595

Please sign in to comment.