Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 510e28e

Browse files
miss-islingtonserhiy-storchaka
andauthoredMay 16, 2025··
[3.13] gh-134109: Fix showing comments in pydoc output for argparse (GH-134110) (GH-134113)
Comments immediately preceding the object's source code are used if the object has no docstring. Comments that do not describe the object should be separated from the following source code by an empty line. (cherry picked from commit 71cf4dd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 4291bbe commit 510e28e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎Lib/argparse.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def __init__(self,
190190
# ===============================
191191
# Section and indentation methods
192192
# ===============================
193+
193194
def _indent(self):
194195
self._current_indent += self._indent_increment
195196
self._level += 1
@@ -237,6 +238,7 @@ def _add_item(self, func, args):
237238
# ========================
238239
# Message building methods
239240
# ========================
241+
240242
def start_section(self, heading):
241243
self._indent()
242244
section = self._Section(self, self._current_section, heading)
@@ -280,6 +282,7 @@ def add_arguments(self, actions):
280282
# =======================
281283
# Help-formatting methods
282284
# =======================
285+
283286
def format_help(self):
284287
help = self._root_section.format_help()
285288
if help:
@@ -1402,6 +1405,7 @@ def __init__(self,
14021405
# ====================
14031406
# Registration methods
14041407
# ====================
1408+
14051409
def register(self, registry_name, value, object):
14061410
registry = self._registries.setdefault(registry_name, {})
14071411
registry[value] = object
@@ -1412,6 +1416,7 @@ def _registry_get(self, registry_name, value, default=None):
14121416
# ==================================
14131417
# Namespace default accessor methods
14141418
# ==================================
1419+
14151420
def set_defaults(self, **kwargs):
14161421
self._defaults.update(kwargs)
14171422

@@ -1431,6 +1436,7 @@ def get_default(self, dest):
14311436
# =======================
14321437
# Adding argument actions
14331438
# =======================
1439+
14341440
def add_argument(self, *args, **kwargs):
14351441
"""
14361442
add_argument(dest, ..., name=value, ...)
@@ -1820,6 +1826,7 @@ def identity(string):
18201826
# =======================
18211827
# Pretty __repr__ methods
18221828
# =======================
1829+
18231830
def _get_kwargs(self):
18241831
names = [
18251832
'prog',
@@ -1834,6 +1841,7 @@ def _get_kwargs(self):
18341841
# ==================================
18351842
# Optional/Positional adding methods
18361843
# ==================================
1844+
18371845
def add_subparsers(self, **kwargs):
18381846
if self._subparsers is not None:
18391847
raise ArgumentError(None, _('cannot have multiple subparser arguments'))
@@ -1885,6 +1893,7 @@ def _get_positional_actions(self):
18851893
# =====================================
18861894
# Command line argument parsing methods
18871895
# =====================================
1896+
18881897
def parse_args(self, args=None, namespace=None):
18891898
args, argv = self.parse_known_args(args, namespace)
18901899
if argv:
@@ -2479,6 +2488,7 @@ def parse_known_intermixed_args(self, args=None, namespace=None):
24792488
# ========================
24802489
# Value conversion methods
24812490
# ========================
2491+
24822492
def _get_values(self, action, arg_strings):
24832493
# optional argument produces a default when not present
24842494
if not arg_strings and action.nargs == OPTIONAL:
@@ -2570,6 +2580,7 @@ def _check_value(self, action, value):
25702580
# =======================
25712581
# Help-formatting methods
25722582
# =======================
2583+
25732584
def format_usage(self):
25742585
formatter = self._get_formatter()
25752586
formatter.add_usage(self.usage, self._actions,
@@ -2605,6 +2616,7 @@ def _get_formatter(self):
26052616
# =====================
26062617
# Help-printing methods
26072618
# =====================
2619+
26082620
def print_usage(self, file=None):
26092621
if file is None:
26102622
file = _sys.stdout
@@ -2626,6 +2638,7 @@ def _print_message(self, message, file=None):
26262638
# ===============
26272639
# Exiting methods
26282640
# ===============
2641+
26292642
def exit(self, status=0, message=None):
26302643
if message:
26312644
self._print_message(message, _sys.stderr)

0 commit comments

Comments
 (0)
Please sign in to comment.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant