Skip to content

Commit 6ae254a

Browse files
authored
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.
1 parent ca5108a commit 6ae254a

File tree

25 files changed

+40
-36
lines changed

25 files changed

+40
-36
lines changed

Lib/_pyio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
_setmode = None
1717

1818
import io
19-
from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END)
19+
from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END) # noqa: F401
2020

2121
valid_seek_flags = {0, 1, 2} # Hardwired values
2222
if hasattr(os, 'SEEK_HOLE') :

Lib/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=Fa
355355
console.raw_input = readfunc
356356
else:
357357
try:
358-
import readline
358+
import readline # noqa: F401
359359
except ImportError:
360360
pass
361361
console.interact(banner, exitmsg)

Lib/codecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,4 +1129,4 @@ def make_encoding_map(decoding_map):
11291129
# package
11301130
_false = 0
11311131
if _false:
1132-
import encodings
1132+
import encodings # noqa: F401

Lib/collections/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
_collections_abc.MutableSequence.register(deque)
4747

4848
try:
49-
from _collections import _deque_iterator
49+
# Expose _deque_iterator to support pickling deque iterators
50+
from _collections import _deque_iterator # noqa: F401
5051
except ImportError:
5152
pass
5253

Lib/concurrent/futures/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def _check_system_limits():
589589
raise NotImplementedError(_system_limited)
590590
_system_limits_checked = True
591591
try:
592-
import multiprocessing.synchronize
592+
import multiprocessing.synchronize # noqa: F401
593593
except ImportError:
594594
_system_limited = (
595595
"This Python build lacks multiprocessing.synchronize, usually due "

Lib/curses/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def start_color():
5353
try:
5454
has_key
5555
except NameError:
56-
from .has_key import has_key
56+
from .has_key import has_key # noqa: F401
5757

5858
# Wrapper for the entire curses-based application. Runs a function which
5959
# should be the rest of your curses-based application. If the application

Lib/datetime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
try:
22
from _datetime import *
3-
from _datetime import __doc__
3+
from _datetime import __doc__ # noqa: F401
44
except ImportError:
55
from _pydatetime import *
6-
from _pydatetime import __doc__
6+
from _pydatetime import __doc__ # noqa: F401
77

88
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
99
"MINYEAR", "MAXYEAR", "UTC")

Lib/decimal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@
100100

101101
try:
102102
from _decimal import *
103-
from _decimal import __version__
104-
from _decimal import __libmpdec_version__
103+
from _decimal import __version__ # noqa: F401
104+
from _decimal import __libmpdec_version__ # noqa: F401
105105
except ImportError:
106106
from _pydecimal import *
107-
from _pydecimal import __version__
108-
from _pydecimal import __libmpdec_version__
107+
from _pydecimal import __version__ # noqa: F401
108+
from _pydecimal import __libmpdec_version__ # noqa: F401

Lib/hashlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def __hash_new(name, data=b'', **kwargs):
187187

188188
try:
189189
# OpenSSL's scrypt requires OpenSSL 1.1+
190-
from _hashlib import scrypt
190+
from _hashlib import scrypt # noqa: F401
191191
except ImportError:
192192
pass
193193

Lib/lzma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import io
2626
import os
2727
from _lzma import *
28-
from _lzma import _encode_filter_properties, _decode_filter_properties
28+
from _lzma import _encode_filter_properties, _decode_filter_properties # noqa: F401
2929
import _compression
3030

3131

0 commit comments

Comments
 (0)