Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add more # noqa for more fun
  • Loading branch information
vstinner committed Jun 12, 2024
commit 19ceb4d6dcde3857b7d535cd61c05c41250f38c8
2 changes: 1 addition & 1 deletion Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
_collections_abc.MutableSequence.register(deque)

try:
from _collections import _deque_iterator
from _collections import _deque_iterator # noqa
except ImportError:
pass
Comment on lines 48 to 52

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_collections passes for me if I remove this import. Does it need to stay? It was added in 52f96d3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erlend-aasland @kumaraditya303: Do you know/recall why this symbol is exposed?

@AlexWaygood AlexWaygood Jun 12, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, test_deque fails if the import is removed. I expected deque to be tested as part of test_collections, but apparently it has its own test file. Could you add a comment that it is (apparently) required to expose it in the collections module in order for deque iterators to be pickled?

======================================================================
ERROR: test_iterator_pickle (test.test_deque.TestBasic.test_iterator_pickle)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/alexw/dev/cpython/Lib/test/test_deque.py", line 640, in test_iterator_pickle
    dump = pickle.dumps((itorg, orig), proto)
_pickle.PicklingError: Can't pickle <class 'collections._deque_iterator'>: attribute lookup _deque_iterator on collections failed

----------------------------------------------------------------------

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added a comment.


Expand Down
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
from _collections_abc import _CallableGenericAlias # noqa
28 changes: 14 additions & 14 deletions Lib/ctypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

__version__ = "1.1.0"

from _ctypes import Union, Structure, Array
from _ctypes import _Pointer
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 SIZEOF_TIME_T
from _ctypes import Union, Structure, Array # noqa
from _ctypes import _Pointer # noqa
from _ctypes import CFuncPtr as _CFuncPtr # noqa
from _ctypes import __version__ as _ctypes_version # noqa
from _ctypes import RTLD_LOCAL, RTLD_GLOBAL # noqa
from _ctypes import ArgumentError # noqa
from _ctypes import SIZEOF_TIME_T # noqa

from struct import calcsize as _calcsize

Expand Down Expand Up @@ -138,9 +138,9 @@ 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 _SimpleCData
from _ctypes import sizeof, byref, addressof, alignment, resize # noqa
from _ctypes import get_errno, set_errno # noqa
from _ctypes import _SimpleCData # noqa

def _check_size(typ, typecode=None):
# Check if sizeof(ctypes_type) against struct.calcsize. This
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

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

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
from ctypes._endian import BigEndianUnion, LittleEndianUnion # noqa

# Fill in specifically-sized types
c_int8 = c_byte
Expand Down
4 changes: 2 additions & 2 deletions Lib/curses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def start_color():
# Import Python has_key() implementation if _curses doesn't contain has_key()

try:
has_key
has_key # noqa
except NameError:
from .has_key import has_key
from .has_key import has_key # noqa

# 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
28 changes: 14 additions & 14 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,
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 import ModuleSpec # noqa
from ._bootstrap import BuiltinImporter # noqa
from ._bootstrap import FrozenImporter # noqa
from ._bootstrap_external import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES, # noqa
OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES, # noqa
EXTENSION_SUFFIXES) # noqa
from ._bootstrap_external import WindowsRegistryFinder # noqa
from ._bootstrap_external import PathFinder # noqa
from ._bootstrap_external import FileFinder # noqa
from ._bootstrap_external import SourceFileLoader # noqa
from ._bootstrap_external import SourcelessFileLoader # noqa
from ._bootstrap_external import ExtensionFileLoader # noqa
from ._bootstrap_external import AppleFrameworkLoader # noqa
from ._bootstrap_external import NamespaceLoader # noqa
Comment thread
AlexWaygood marked this conversation as resolved.
Outdated


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
from ._bootstrap import _resolve_name
from ._bootstrap import spec_from_loader
from ._bootstrap import spec_from_loader # noqa
from ._bootstrap import _find_spec
from ._bootstrap_external import MAGIC_NUMBER
from ._bootstrap_external import MAGIC_NUMBER # noqa
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
from ._bootstrap_external import decode_source # noqa
from ._bootstrap_external import source_from_cache # noqa
from ._bootstrap_external import spec_from_file_location # noqa

import _imp
import sys
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

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/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

# SRE standard exception (access as sre.error)
# should this really be here?
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
except ImportError:
pass
console.interact(banner, exitmsg="")
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
except ImportError:
_have_ssl = False
else:
Expand Down