Skip to content

Commit ed07df1

Browse files
gfyoungjreback
authored andcommitted
CLN: Remove "flake8: noqa" from even more files
Another round of house-cleaning that builds off #15867. Likely to be the last one for now. Author: gfyoung <[email protected]> Closes #15872 from gfyoung/flake8-noqa-clean and squashes the following commits: 3e610f5 [gfyoung] CLN: Make pickle_compat.py flake8-able 05e067a [gfyoung] CLN: Make windows.py flake8-able dc22c0a [gfyoung] CLN: Make clipboards.py flake8-able 90b00f0 [gfyoung] CLN: Make clipboard/__init__.py flake8-able ccb44cc [gfyoung] CLN: Make engines.py flake8-able
1 parent b199fbf commit ed07df1

File tree

5 files changed

+41
-34
lines changed

5 files changed

+41
-34
lines changed

pandas/compat/pickle_compat.py

+33-21
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
""" support pre 0.12 series pickle compatibility """
2-
3-
# flake8: noqa
1+
"""
2+
Support pre-0.12 series pickle compatibility.
3+
"""
44

55
import sys
6-
import pandas
6+
import pandas # noqa
77
import copy
88
import pickle as pkl
99
from pandas import compat, Index
10-
from pandas.compat import u, string_types
10+
from pandas.compat import u, string_types # noqa
1111

1212

1313
def load_reduce(self):
@@ -16,25 +16,27 @@ def load_reduce(self):
1616
func = stack[-1]
1717

1818
if type(args[0]) is type:
19-
n = args[0].__name__
19+
n = args[0].__name__ # noqa
2020

2121
try:
2222
stack[-1] = func(*args)
2323
return
2424
except Exception as e:
2525

26-
# if we have a deprecated function
27-
# try to replace and try again
26+
# If we have a deprecated function,
27+
# try to replace and try again.
28+
29+
msg = '_reconstruct: First argument must be a sub-type of ndarray'
2830

29-
if '_reconstruct: First argument must be a sub-type of ndarray' in str(e):
31+
if msg in str(e):
3032
try:
3133
cls = args[0]
3234
stack[-1] = object.__new__(cls)
3335
return
3436
except:
3537
pass
3638

37-
# try to reencode the arguments
39+
# try to re-encode the arguments
3840
if getattr(self, 'encoding', None) is not None:
3941
args = tuple([arg.encode(self.encoding)
4042
if isinstance(arg, string_types)
@@ -45,31 +47,37 @@ def load_reduce(self):
4547
except:
4648
pass
4749

50+
# unknown exception, re-raise
4851
if getattr(self, 'is_verbose', None):
4952
print(sys.exc_info())
5053
print(func, args)
5154
raise
5255

53-
stack[-1] = value
5456

55-
56-
# if classes are moved, provide compat here
57+
# If classes are moved, provide compat here.
5758
_class_locations_map = {
5859

5960
# 15477
60-
('pandas.core.base', 'FrozenNDArray'): ('pandas.indexes.frozen', 'FrozenNDArray'),
61-
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList'),
61+
('pandas.core.base', 'FrozenNDArray'):
62+
('pandas.indexes.frozen', 'FrozenNDArray'),
63+
('pandas.core.base', 'FrozenList'):
64+
('pandas.indexes.frozen', 'FrozenList'),
6265

6366
# 10890
64-
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series'),
65-
('pandas.sparse.series', 'SparseTimeSeries'): ('pandas.sparse.series', 'SparseSeries'),
67+
('pandas.core.series', 'TimeSeries'):
68+
('pandas.core.series', 'Series'),
69+
('pandas.sparse.series', 'SparseTimeSeries'):
70+
('pandas.sparse.series', 'SparseSeries'),
6671

6772
# 12588, extensions moving
68-
('pandas._sparse', 'BlockIndex'): ('pandas.sparse.libsparse', 'BlockIndex'),
69-
('pandas.tslib', 'Timestamp'): ('pandas._libs.tslib', 'Timestamp'),
70-
('pandas.tslib', '__nat_unpickle'): ('pandas._libs.tslib', '__nat_unpickle'),
73+
('pandas._sparse', 'BlockIndex'):
74+
('pandas.sparse.libsparse', 'BlockIndex'),
75+
('pandas.tslib', 'Timestamp'):
76+
('pandas._libs.tslib', 'Timestamp'),
77+
('pandas.tslib', '__nat_unpickle'):
78+
('pandas._libs.tslib', '__nat_unpickle'),
7179
('pandas._period', 'Period'): ('pandas._libs.period', 'Period')
72-
}
80+
}
7381

7482

7583
# our Unpickler sub-class to override methods and some dispatcher
@@ -112,6 +120,8 @@ def load_newobj(self):
112120
obj = cls.__new__(cls, *args)
113121

114122
self.stack[-1] = obj
123+
124+
115125
Unpickler.dispatch[pkl.NEWOBJ[0]] = load_newobj
116126

117127

@@ -126,6 +136,8 @@ def load_newobj_ex(self):
126136
else:
127137
obj = cls.__new__(cls, *args, **kwargs)
128138
self.append(obj)
139+
140+
129141
try:
130142
Unpickler.dispatch[pkl.NEWOBJ_EX[0]] = load_newobj_ex
131143
except:

pandas/computation/engines.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
"""Engine classes for :func:`~pandas.eval`
21
"""
3-
4-
# flake8: noqa
2+
Engine classes for :func:`~pandas.eval`
3+
"""
54

65
import abc
76

87
from pandas import compat
9-
from pandas.compat import DeepChainMap, map
10-
import pandas.core.common as com
8+
from pandas.compat import map
119
import pandas.formats.printing as printing
1210
from pandas.computation.align import _align, _reconstruct_object
1311
from pandas.computation.ops import (UndefinedVariableError,

pandas/util/clipboard/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
"""
2626
__version__ = '1.5.27'
2727

28-
# flake8: noqa
29-
3028
import platform
3129
import os
3230
import subprocess
@@ -62,14 +60,16 @@ def determine_clipboard():
6260
if HAS_DISPLAY:
6361
# Determine which command/module is installed, if any.
6462
try:
65-
import gtk # check if gtk is installed
63+
# Check if gtk is installed
64+
import gtk # noqa
6665
except ImportError:
6766
pass
6867
else:
6968
return init_gtk_clipboard()
7069

7170
try:
72-
import PyQt4 # check if PyQt4 is installed
71+
# Check if PyQt4 is installed
72+
import PyQt4 # noqa
7373
except ImportError:
7474
pass
7575
else:

pandas/util/clipboard/clipboards.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# flake8: noqa
2-
31
import sys
42
import subprocess
53
from .exceptions import PyperclipException
@@ -8,7 +6,7 @@
86
Pyperclip could not find a copy/paste mechanism for your system.
97
For more information, please visit https://pyperclip.readthedocs.org """
108
PY2 = sys.version_info[0] == 2
11-
text_type = unicode if PY2 else str
9+
text_type = unicode if PY2 else str # noqa
1210

1311

1412
def init_osx_clipboard():

pandas/util/clipboard/windows.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa
21
"""
32
This module implements clipboard handling on Windows using ctypes.
43
"""

0 commit comments

Comments
 (0)