summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-06-13 14:14:50 (GMT)
committerGitHub <noreply@github.com>2024-06-13 14:14:50 (GMT)
commit6ae254aaa0a5a3985a52d1ab387a2b68c001bd96 (patch)
tree09a2b03e9721203f5b6b523fbb26db13f36e8569 /Lib
parentca5108a46d5da3978d4bd29717ea3fbdee772e66 (diff)
downloadcpython-6ae254aaa0a5a3985a52d1ab387a2b68c001bd96.zip
cpython-6ae254aaa0a5a3985a52d1ab387a2b68c001bd96.tar.gz
cpython-6ae254aaa0a5a3985a52d1ab387a2b68c001bd96.tar.bz2
gh-120417: Add #noqa to used imports in the stdlib (#120421)
Tools such as ruff can ignore "imported but unused" warnings if a line ends with "# noqa: F401". It avoids the temptation to remove an import which is used effectively.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_pyio.py2
-rw-r--r--Lib/code.py2
-rw-r--r--Lib/codecs.py2
-rw-r--r--Lib/collections/__init__.py3
-rw-r--r--Lib/concurrent/futures/process.py2
-rw-r--r--Lib/curses/__init__.py2
-rw-r--r--Lib/datetime.py4
-rw-r--r--Lib/decimal.py8
-rw-r--r--Lib/hashlib.py2
-rw-r--r--Lib/lzma.py2
-rw-r--r--Lib/multiprocessing/context.py2
-rw-r--r--Lib/multiprocessing/util.py2
-rw-r--r--Lib/opcode.py4
-rw-r--r--Lib/operator.py2
-rw-r--r--Lib/platform.py2
-rw-r--r--Lib/pstats.py2
-rw-r--r--Lib/pydoc.py5
-rw-r--r--Lib/re/_constants.py2
-rw-r--r--Lib/site.py6
-rw-r--r--Lib/sqlite3/__main__.py2
-rw-r--r--Lib/struct.py4
-rw-r--r--Lib/symtable.py6
-rw-r--r--Lib/unittest/__init__.py4
-rw-r--r--Lib/urllib/request.py2
-rw-r--r--Lib/xml/dom/__init__.py2
25 files changed, 40 insertions, 36 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index a3fede6..7d298e1 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -16,7 +16,7 @@ else:
_setmode = None
import io
-from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END)
+from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END) # noqa: F401
valid_seek_flags = {0, 1, 2} # Hardwired values
if hasattr(os, 'SEEK_HOLE') :
diff --git a/Lib/code.py b/Lib/code.py
index b93902c..a55fced 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -355,7 +355,7 @@ def interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=Fa
console.raw_input = readfunc
else:
try:
- import readline
+ import readline # noqa: F401
except ImportError:
pass
console.interact(banner, exitmsg)
diff --git a/Lib/codecs.py b/Lib/codecs.py
index 9b35b61..a887e5d 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -1129,4 +1129,4 @@ except LookupError:
# package
_false = 0
if _false:
- import encodings
+ import encodings # noqa: F401
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index a17100e..b47e728 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -46,7 +46,8 @@ else:
_collections_abc.MutableSequence.register(deque)
try:
- from _collections import _deque_iterator
+ # Expose _deque_iterator to support pickling deque iterators
+ from _collections import _deque_iterator # noqa: F401
except ImportError:
pass
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py
index bb4892e..7092b47 100644
--- a/Lib/concurrent/futures/process.py
+++ b/Lib/concurrent/futures/process.py
@@ -589,7 +589,7 @@ def _check_system_limits():
raise NotImplementedError(_system_limited)
_system_limits_checked = True
try:
- import multiprocessing.synchronize
+ import multiprocessing.synchronize # noqa: F401
except ImportError:
_system_limited = (
"This Python build lacks multiprocessing.synchronize, usually due "
diff --git a/Lib/curses/__init__.py b/Lib/curses/__init__.py
index 69270bf..6165fe6 100644
--- a/Lib/curses/__init__.py
+++ b/Lib/curses/__init__.py
@@ -53,7 +53,7 @@ def start_color():
try:
has_key
except NameError:
- from .has_key import has_key
+ from .has_key import has_key # noqa: F401
# Wrapper for the entire curses-based application. Runs a function which
# should be the rest of your curses-based application. If the application
diff --git a/Lib/datetime.py b/Lib/datetime.py
index a33d2d7..b4f7bd0 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -1,9 +1,9 @@
try:
from _datetime import *
- from _datetime import __doc__
+ from _datetime import __doc__ # noqa: F401
except ImportError:
from _pydatetime import *
- from _pydatetime import __doc__
+ from _pydatetime import __doc__ # noqa: F401
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
"MINYEAR", "MAXYEAR", "UTC")
diff --git a/Lib/decimal.py b/Lib/decimal.py
index d61e374..13a0dcb 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -100,9 +100,9 @@ NaN
try:
from _decimal import *
- from _decimal import __version__
- from _decimal import __libmpdec_version__
+ from _decimal import __version__ # noqa: F401
+ from _decimal import __libmpdec_version__ # noqa: F401
except ImportError:
from _pydecimal import *
- from _pydecimal import __version__
- from _pydecimal import __libmpdec_version__
+ from _pydecimal import __version__ # noqa: F401
+ from _pydecimal import __libmpdec_version__ # noqa: F401
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
index 1b16441..da05770 100644
--- a/Lib/hashlib.py
+++ b/Lib/hashlib.py
@@ -187,7 +187,7 @@ except ImportError:
try:
# OpenSSL's scrypt requires OpenSSL 1.1+
- from _hashlib import scrypt
+ from _hashlib import scrypt # noqa: F401
except ImportError:
pass
diff --git a/Lib/lzma.py b/Lib/lzma.py
index c1e3d33..946066a 100644
--- a/Lib/lzma.py
+++ b/Lib/lzma.py
@@ -25,7 +25,7 @@ import builtins
import io
import os
from _lzma import *
-from _lzma import _encode_filter_properties, _decode_filter_properties
+from _lzma import _encode_filter_properties, _decode_filter_properties # noqa: F401
import _compression
diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py
index de8a264..ddcc7e7 100644
--- a/Lib/multiprocessing/context.py
+++ b/Lib/multiprocessing/context.py
@@ -167,7 +167,7 @@ class BaseContext(object):
'''
# This is undocumented. In previous versions of multiprocessing
# its only effect was to make socket objects inheritable on Windows.
- from . import connection
+ from . import connection # noqa: F401
def set_executable(self, executable):
'''Sets the path to a python.exe or pythonw.exe binary used to run
diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py
index 75dde02..4f471fb 100644
--- a/Lib/multiprocessing/util.py
+++ b/Lib/multiprocessing/util.py
@@ -14,7 +14,7 @@ import weakref
import atexit
import threading # we want threading to install it's
# cleanup function before multiprocessing does
-from subprocess import _args_from_interpreter_flags
+from subprocess import _args_from_interpreter_flags # noqa: F401
from . import process
diff --git a/Lib/opcode.py b/Lib/opcode.py
index 85e37ff..85c0834 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -12,8 +12,8 @@ __all__ = ["cmp_op", "stack_effect", "hascompare", "opname", "opmap",
import _opcode
from _opcode import stack_effect
-from _opcode_metadata import (_specializations, _specialized_opmap, opmap,
- HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE)
+from _opcode_metadata import (_specializations, _specialized_opmap, opmap, # noqa: F401
+ HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) # noqa: F401
EXTENDED_ARG = opmap['EXTENDED_ARG']
opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
diff --git a/Lib/operator.py b/Lib/operator.py
index 02ccdaa..6d2a762 100644
--- a/Lib/operator.py
+++ b/Lib/operator.py
@@ -415,7 +415,7 @@ try:
except ImportError:
pass
else:
- from _operator import __doc__
+ from _operator import __doc__ # noqa: F401
# All of these "__func__ = func" assignments have to happen after importing
# from _operator to make sure they're set to the right function
diff --git a/Lib/platform.py b/Lib/platform.py
index a4fd246..d6322c9d 100644
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -546,7 +546,7 @@ def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):
warnings._deprecated('java_ver', remove=(3, 15))
# Import the needed APIs
try:
- import java.lang
+ import java.lang # noqa: F401
except ImportError:
return release, vendor, vminfo, osinfo
diff --git a/Lib/pstats.py b/Lib/pstats.py
index 2f054bb..a174a54 100644
--- a/Lib/pstats.py
+++ b/Lib/pstats.py
@@ -611,7 +611,7 @@ def f8(x):
if __name__ == '__main__':
import cmd
try:
- import readline
+ import readline # noqa: F401
except ImportError:
pass
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 278e484..be5cd9a 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -75,9 +75,12 @@ from collections import deque
from reprlib import Repr
from traceback import format_exception_only
-from _pyrepl.pager import (get_pager, plain, pipe_pager,
+from _pyrepl.pager import (get_pager, pipe_pager,
plain_pager, tempfile_pager, tty_pager)
+# Expose plain() as pydoc.plain()
+from _pyrepl.pager import plain # noqa: F401
+
# --------------------------------------------------------- old names
diff --git a/Lib/re/_constants.py b/Lib/re/_constants.py
index 9c3c294..4cb88c9 100644
--- a/Lib/re/_constants.py
+++ b/Lib/re/_constants.py
@@ -15,7 +15,7 @@
MAGIC = 20230612
-from _sre import MAXREPEAT, MAXGROUPS
+from _sre import MAXREPEAT, MAXGROUPS # noqa: F401
# SRE standard exception (access as sre.error)
# should this really be here?
diff --git a/Lib/site.py b/Lib/site.py
index 7eace19..9381f6f 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -486,7 +486,7 @@ def register_readline():
import atexit
try:
import readline
- import rlcompleter
+ import rlcompleter # noqa: F401
import _pyrepl.readline
import _pyrepl.unix_console
except ImportError:
@@ -603,7 +603,7 @@ def execsitecustomize():
"""Run custom site specific code, if available."""
try:
try:
- import sitecustomize
+ import sitecustomize # noqa: F401
except ImportError as exc:
if exc.name == 'sitecustomize':
pass
@@ -623,7 +623,7 @@ def execusercustomize():
"""Run custom user specific code, if available."""
try:
try:
- import usercustomize
+ import usercustomize # noqa: F401
except ImportError as exc:
if exc.name == 'usercustomize':
pass
diff --git a/Lib/sqlite3/__main__.py b/Lib/sqlite3/__main__.py
index b93b843..d9423c2 100644
--- a/Lib/sqlite3/__main__.py
+++ b/Lib/sqlite3/__main__.py
@@ -117,7 +117,7 @@ def main(*args):
# No SQL provided; start the REPL.
console = SqliteInteractiveConsole(con)
try:
- import readline
+ import readline # noqa: F401
except ImportError:
pass
console.interact(banner, exitmsg="")
diff --git a/Lib/struct.py b/Lib/struct.py
index d6bba58..ff98e8c 100644
--- a/Lib/struct.py
+++ b/Lib/struct.py
@@ -11,5 +11,5 @@ __all__ = [
]
from _struct import *
-from _struct import _clearcache
-from _struct import __doc__
+from _struct import _clearcache # noqa: F401
+from _struct import __doc__ # noqa: F401
diff --git a/Lib/symtable.py b/Lib/symtable.py
index d6ac1f5..f8ba349 100644
--- a/Lib/symtable.py
+++ b/Lib/symtable.py
@@ -3,9 +3,9 @@
import _symtable
from _symtable import (
USE,
- DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL,
- DEF_PARAM, DEF_TYPE_PARAM,
- DEF_FREE_CLASS,
+ DEF_GLOBAL, # noqa: F401
+ DEF_NONLOCAL, DEF_LOCAL,
+ DEF_PARAM, DEF_TYPE_PARAM, DEF_FREE_CLASS,
DEF_IMPORT, DEF_BOUND, DEF_ANNOT,
DEF_COMP_ITER, DEF_COMP_CELL,
SCOPE_OFF, SCOPE_MASK,
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py
index f1f6c91..324e5d0 100644
--- a/Lib/unittest/__init__.py
+++ b/Lib/unittest/__init__.py
@@ -57,9 +57,9 @@ from .result import TestResult
from .case import (addModuleCleanup, TestCase, FunctionTestCase, SkipTest, skip,
skipIf, skipUnless, expectedFailure, doModuleCleanups,
enterModuleContext)
-from .suite import BaseTestSuite, TestSuite
+from .suite import BaseTestSuite, TestSuite # noqa: F401
from .loader import TestLoader, defaultTestLoader
-from .main import TestProgram, main
+from .main import TestProgram, main # noqa: F401
from .runner import TextTestRunner, TextTestResult
from .signals import installHandler, registerResult, removeResult, removeHandler
# IsolatedAsyncioTestCase will be imported lazily.
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index ac6719c..58b0cb5 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -108,7 +108,7 @@ from urllib.response import addinfourl, addclosehook
# check for SSL
try:
- import ssl
+ import ssl # noqa: F401
except ImportError:
_have_ssl = False
else:
diff --git a/Lib/xml/dom/__init__.py b/Lib/xml/dom/__init__.py
index 97cf9a6..dd7fb99 100644
--- a/Lib/xml/dom/__init__.py
+++ b/Lib/xml/dom/__init__.py
@@ -137,4 +137,4 @@ XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"
EMPTY_NAMESPACE = None
EMPTY_PREFIX = None
-from .domreg import getDOMImplementation, registerDOMImplementation
+from .domreg import getDOMImplementation, registerDOMImplementation # noqa: F401