Skip to content

gh-120417: Add #noqa to used imports in the stdlib #120421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_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') :
Expand Down
2 changes: 1 addition & 1 deletion Lib/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Lib/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,4 +1129,4 @@ def make_encoding_map(decoding_map):
# package
_false = 0
if _false:
import encodings
import encodings # noqa: F401
3 changes: 2 additions & 1 deletion Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
_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

Expand Down
2 changes: 1 addition & 1 deletion Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
2 changes: 1 addition & 1 deletion Lib/curses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Lib/datetime.py
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 4 additions & 4 deletions Lib/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@

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
2 changes: 1 addition & 1 deletion Lib/hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __hash_new(name, data=b'', **kwargs):

try:
# OpenSSL's scrypt requires OpenSSL 1.1+
from _hashlib import scrypt
from _hashlib import scrypt # noqa: F401
except ImportError:
pass

Expand Down
2 changes: 1 addition & 1 deletion Lib/lzma.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
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


Expand Down
2 changes: 1 addition & 1 deletion Lib/multiprocessing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def allow_connection_pickling(self):
'''
# 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
Expand Down
2 changes: 1 addition & 1 deletion Lib/multiprocessing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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

Expand Down
4 changes: 2 additions & 2 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
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)]
Expand Down
2 changes: 1 addition & 1 deletion Lib/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def ixor(a, b):
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
Expand Down
2 changes: 1 addition & 1 deletion Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Lib/pstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def f8(x):
if __name__ == '__main__':
import cmd
try:
import readline
import readline # noqa: F401
except ImportError:
pass

Expand Down
5 changes: 4 additions & 1 deletion Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ class or function within a module or module in a package. If the
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

Expand Down
2 changes: 1 addition & 1 deletion Lib/re/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
6 changes: 3 additions & 3 deletions Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Lib/sqlite3/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="")
Expand Down
4 changes: 2 additions & 2 deletions Lib/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
]

from _struct import *
from _struct import _clearcache
from _struct import __doc__
from _struct import _clearcache # noqa: F401
from _struct import __doc__ # noqa: F401
6 changes: 3 additions & 3 deletions Lib/symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions Lib/unittest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def testMultiply(self):
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.
Expand Down
2 changes: 1 addition & 1 deletion Lib/urllib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

# check for SSL
try:
import ssl
import ssl # noqa: F401
except ImportError:
_have_ssl = False
else:
Expand Down
2 changes: 1 addition & 1 deletion Lib/xml/dom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ class UserDataHandler:
EMPTY_NAMESPACE = None
EMPTY_PREFIX = None

from .domreg import getDOMImplementation, registerDOMImplementation
from .domreg import getDOMImplementation, registerDOMImplementation # noqa: F401
Loading