summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-10-04 05:09:43 (GMT)
committerGitHub <noreply@github.com>2023-10-04 05:09:43 (GMT)
commitbfe7e72522565f828f43c2591fea84a7981ee048 (patch)
treec1602e78494734ac325d395f51a74fe55bb8d5c7 /Lib/argparse.py
parentf02f26e29366513b097578fbc6b25e02d0eba7c0 (diff)
downloadcpython-bfe7e72522565f828f43c2591fea84a7981ee048.zip
cpython-bfe7e72522565f828f43c2591fea84a7981ee048.tar.gz
cpython-bfe7e72522565f828f43c2591fea84a7981ee048.tar.bz2
gh-109653: Defer importing `warnings` in several modules (#110286)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index dfc9869..a32884d 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -89,8 +89,6 @@ import os as _os
import re as _re
import sys as _sys
-import warnings
-
from gettext import gettext as _, ngettext
SUPPRESS = '==SUPPRESS=='
@@ -910,6 +908,7 @@ class BooleanOptionalAction(Action):
# parser.add_argument('-f', action=BooleanOptionalAction, type=int)
for field_name in ('type', 'choices', 'metavar'):
if locals()[field_name] is not _deprecated_default:
+ import warnings
warnings._deprecated(
field_name,
"{name!r} is deprecated as of Python 3.12 and will be "
@@ -1700,6 +1699,7 @@ class _ArgumentGroup(_ActionsContainer):
self._group_actions.remove(action)
def add_argument_group(self, *args, **kwargs):
+ import warnings
warnings.warn(
"Nesting argument groups is deprecated.",
category=DeprecationWarning,
@@ -1728,6 +1728,7 @@ class _MutuallyExclusiveGroup(_ArgumentGroup):
self._group_actions.remove(action)
def add_mutually_exclusive_group(self, *args, **kwargs):
+ import warnings
warnings.warn(
"Nesting mutually exclusive groups is deprecated.",
category=DeprecationWarning,