Skip to content

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

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions Lib/collections/abc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from _collections_abc import *
from _collections_abc import __all__
from _collections_abc import _CallableGenericAlias
from _collections_abc import __all__ # noqa: F401
from _collections_abc import _CallableGenericAlias # noqa: F401
18 changes: 9 additions & 9 deletions Lib/ctypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

__version__ = "1.1.0"

from _ctypes import Union, Structure, Array
from _ctypes import _Pointer
from _ctypes import Union, Structure, Array # noqa: F401
from _ctypes import _Pointer # noqa: F401
from _ctypes import CFuncPtr as _CFuncPtr
from _ctypes import __version__ as _ctypes_version
from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
from _ctypes import ArgumentError
from _ctypes import ArgumentError # noqa: F401
from _ctypes import SIZEOF_TIME_T

from struct import calcsize as _calcsize
Expand Down Expand Up @@ -138,8 +138,8 @@ class WinFunctionType(_CFuncPtr):
elif _os.name == "posix":
from _ctypes import dlopen as _dlopen

from _ctypes import sizeof, byref, addressof, alignment, resize
from _ctypes import get_errno, set_errno
from _ctypes import sizeof, byref, addressof, alignment, resize # noqa: F401
from _ctypes import get_errno, set_errno # noqa: F401
from _ctypes import _SimpleCData

def _check_size(typ, typecode=None):
Expand Down Expand Up @@ -252,7 +252,7 @@ class c_void_p(_SimpleCData):
class c_bool(_SimpleCData):
_type_ = "?"

from _ctypes import POINTER, pointer, _pointer_type_cache
from _ctypes import POINTER, pointer, _pointer_type_cache # noqa: F401

class c_wchar_p(_SimpleCData):
_type_ = "Z"
Expand Down Expand Up @@ -492,7 +492,7 @@ def LoadLibrary(self, name):
oledll = LibraryLoader(OleDLL)

GetLastError = windll.kernel32.GetLastError
from _ctypes import get_last_error, set_last_error
from _ctypes import get_last_error, set_last_error # noqa: F401

def WinError(code=None, descr=None):
if code is None:
Expand Down Expand Up @@ -568,8 +568,8 @@ def DllCanUnloadNow():
return 0 # S_OK
return ccom.DllCanUnloadNow()

from ctypes._endian import BigEndianStructure, LittleEndianStructure
from ctypes._endian import BigEndianUnion, LittleEndianUnion
from ctypes._endian import BigEndianStructure, LittleEndianStructure # noqa: F401
from ctypes._endian import BigEndianUnion, LittleEndianUnion # noqa: F401

# Fill in specifically-sized types
c_int8 = c_byte
Expand Down
24 changes: 12 additions & 12 deletions Lib/importlib/machinery.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""The machinery of importlib: finders, loaders, hooks, etc."""

from ._bootstrap import ModuleSpec
from ._bootstrap import BuiltinImporter
from ._bootstrap import FrozenImporter
from ._bootstrap_external import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES,
from ._bootstrap import ModuleSpec # noqa: F401
from ._bootstrap import BuiltinImporter # noqa: F401
from ._bootstrap import FrozenImporter # noqa: F401
from ._bootstrap_external import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES, # noqa: F401
OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES,
EXTENSION_SUFFIXES)
from ._bootstrap_external import WindowsRegistryFinder
from ._bootstrap_external import PathFinder
from ._bootstrap_external import FileFinder
from ._bootstrap_external import SourceFileLoader
from ._bootstrap_external import SourcelessFileLoader
from ._bootstrap_external import ExtensionFileLoader
from ._bootstrap_external import AppleFrameworkLoader
from ._bootstrap_external import NamespaceLoader
from ._bootstrap_external import WindowsRegistryFinder # noqa: F401
from ._bootstrap_external import PathFinder # noqa: F401
from ._bootstrap_external import FileFinder # noqa: F401
from ._bootstrap_external import SourceFileLoader # noqa: F401
from ._bootstrap_external import SourcelessFileLoader # noqa: F401
from ._bootstrap_external import ExtensionFileLoader # noqa: F401
from ._bootstrap_external import AppleFrameworkLoader # noqa: F401
from ._bootstrap_external import NamespaceLoader # noqa: F401


def all_suffixes():
Expand Down
14 changes: 7 additions & 7 deletions Lib/importlib/util.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Utility code for constructing importers, etc."""
from ._abc import Loader
from ._bootstrap import module_from_spec
from ._bootstrap import module_from_spec # noqa: F401
from ._bootstrap import _resolve_name
from ._bootstrap import spec_from_loader
from ._bootstrap import spec_from_loader # noqa: F401
from ._bootstrap import _find_spec
from ._bootstrap_external import MAGIC_NUMBER
from ._bootstrap_external import MAGIC_NUMBER # noqa: F401
from ._bootstrap_external import _RAW_MAGIC_NUMBER
from ._bootstrap_external import cache_from_source
from ._bootstrap_external import decode_source
from ._bootstrap_external import source_from_cache
from ._bootstrap_external import spec_from_file_location
from ._bootstrap_external import cache_from_source # noqa: F401
from ._bootstrap_external import decode_source # noqa: F401
from ._bootstrap_external import source_from_cache # noqa: F401
from ._bootstrap_external import spec_from_file_location # noqa: F401

import _imp
import sys
Expand Down
20 changes: 10 additions & 10 deletions Lib/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,26 @@

import _ssl # if we can't import it, let the error propagate

from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION # noqa: F401
from _ssl import _SSLContext, MemoryBIO, SSLSession # noqa: F401
from _ssl import (
SSLError, SSLZeroReturnError, SSLWantReadError, SSLWantWriteError,
SSLSyscallError, SSLEOFError, SSLCertVerificationError
SSLError, SSLZeroReturnError, SSLWantReadError, SSLWantWriteError, # noqa: F401
SSLSyscallError, SSLEOFError, SSLCertVerificationError # noqa: F401
)
from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj
from _ssl import RAND_status, RAND_add, RAND_bytes
from _ssl import RAND_status, RAND_add, RAND_bytes # noqa: F401
try:
from _ssl import RAND_egd
from _ssl import RAND_egd # noqa: F401
except ImportError:
# RAND_egd is not supported on some platforms
pass


from _ssl import (
HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN, HAS_SSLv2, HAS_SSLv3, HAS_TLSv1,
HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3, HAS_PSK
HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN, HAS_SSLv2, HAS_SSLv3, HAS_TLSv1, # noqa: F401
HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3, HAS_PSK # noqa: F401
)
from _ssl import _DEFAULT_CIPHERS, _OPENSSL_API_VERSION
from _ssl import _DEFAULT_CIPHERS, _OPENSSL_API_VERSION # noqa: F401

_IntEnum._convert_(
'_SSLMethod', __name__,
Expand Down Expand Up @@ -255,7 +255,7 @@ class _TLSMessageType:


if sys.platform == "win32":
from _ssl import enum_certificates, enum_crls
from _ssl import enum_certificates, enum_crls # noqa: F401

from socket import socket, SOCK_STREAM, create_connection
from socket import SOL_SOCKET, SO_TYPE, _GLOBAL_DEFAULT_TIMEOUT
Expand Down
2 changes: 1 addition & 1 deletion Lib/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

if _mswindows:
import _winapi
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP, # noqa: F401
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
STD_ERROR_HANDLE, SW_HIDE,
STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW,
Expand Down
10 changes: 5 additions & 5 deletions Lib/xml/sax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"""

from .xmlreader import InputSource
from .handler import ContentHandler, ErrorHandler
from ._exceptions import SAXException, SAXNotRecognizedException, \
SAXParseException, SAXNotSupportedException, \
SAXReaderNotAvailable
from .handler import ContentHandler, ErrorHandler # noqa: F401
from ._exceptions import (SAXException, SAXNotRecognizedException, # noqa: F401
SAXParseException, SAXNotSupportedException, # noqa: F401
SAXReaderNotAvailable) # noqa: F401


def parse(source, handler, errorHandler=ErrorHandler()):
Expand Down Expand Up @@ -55,7 +55,7 @@ def parseString(string, handler, errorHandler=ErrorHandler()):
# tell modulefinder that importing sax potentially imports expatreader
_false = 0
if _false:
import xml.sax.expatreader
import xml.sax.expatreader # noqa: F401

import os, sys
if not sys.flags.ignore_environment and "PY_SAX_PARSER" in os.environ:
Expand Down
Loading