Skip to content

CLN: Remove "flake8: noqa" from even more files #15872

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 5 commits 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
53 changes: 32 additions & 21 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
""" support pre 0.12 series pickle compatibility """

# flake8: noqa
"""
Support pre-0.12 series pickle compatibility.
"""

import sys
import pandas
import pandas # noqa
import copy
import pickle as pkl
from pandas import compat, Index
from pandas.compat import u, string_types
from pandas.compat import u, string_types # noqa


def load_reduce(self):
Expand All @@ -16,25 +16,27 @@ def load_reduce(self):
func = stack[-1]

if type(args[0]) is type:
n = args[0].__name__
n = args[0].__name__ # noqa

try:
stack[-1] = func(*args)
return
except Exception as e:

# if we have a deprecated function
# try to replace and try again
# If we have a deprecated function,
# try to replace and try again.

msg = '_reconstruct: First argument must be a sub-type of ndarray'

if '_reconstruct: First argument must be a sub-type of ndarray' in str(e):
if msg in str(e):
try:
cls = args[0]
stack[-1] = object.__new__(cls)
return
except:
pass

# try to reencode the arguments
# try to re-encode the arguments
if getattr(self, 'encoding', None) is not None:
args = tuple([arg.encode(self.encoding)
if isinstance(arg, string_types)
Expand All @@ -50,26 +52,31 @@ def load_reduce(self):
print(func, args)
raise

stack[-1] = value
Copy link
Contributor

Choose a reason for hiding this comment

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

? was this just a copy-paste error?

Copy link
Member Author

@gfyoung gfyoung Apr 3, 2017

Choose a reason for hiding this comment

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

Honestly, I have no idea. You should ask yourself that 😄 (your name shows up when I look at the blame for this file)

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, what IS puzzling is that it still works! ok thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Because Python isn't an interpreted language 😄 (that line of code is unreachable, so we can never get an error there)?

Copy link
Contributor

Choose a reason for hiding this comment

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

    def load_reduce(self):
        stack = self.stack
        args = stack.pop()
        func = stack[-1]
        stack[-1] = func(*args)

was the original code

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I see. Are my changes fine as is still?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, had a bunch of error conditions. That statement was dead code :>



# if classes are moved, provide compat here
# If classes are moved, provide compat here.
_class_locations_map = {

# 15477
('pandas.core.base', 'FrozenNDArray'): ('pandas.indexes.frozen', 'FrozenNDArray'),
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList'),
('pandas.core.base', 'FrozenNDArray'):
('pandas.indexes.frozen', 'FrozenNDArray'),
('pandas.core.base', 'FrozenList'):
('pandas.indexes.frozen', 'FrozenList'),

# 10890
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series'),
('pandas.sparse.series', 'SparseTimeSeries'): ('pandas.sparse.series', 'SparseSeries'),
('pandas.core.series', 'TimeSeries'):
('pandas.core.series', 'Series'),
('pandas.sparse.series', 'SparseTimeSeries'):
('pandas.sparse.series', 'SparseSeries'),

# 12588, extensions moving
('pandas._sparse', 'BlockIndex'): ('pandas.sparse.libsparse', 'BlockIndex'),
('pandas.tslib', 'Timestamp'): ('pandas._libs.tslib', 'Timestamp'),
('pandas.tslib', '__nat_unpickle'): ('pandas._libs.tslib', '__nat_unpickle'),
('pandas._sparse', 'BlockIndex'):
('pandas.sparse.libsparse', 'BlockIndex'),
('pandas.tslib', 'Timestamp'):
('pandas._libs.tslib', 'Timestamp'),
('pandas.tslib', '__nat_unpickle'):
('pandas._libs.tslib', '__nat_unpickle'),
('pandas._period', 'Period'): ('pandas._libs.period', 'Period')
}
}


# our Unpickler sub-class to override methods and some dispatcher
Expand Down Expand Up @@ -112,6 +119,8 @@ def load_newobj(self):
obj = cls.__new__(cls, *args)

self.stack[-1] = obj


Unpickler.dispatch[pkl.NEWOBJ[0]] = load_newobj


Expand All @@ -126,6 +135,8 @@ def load_newobj_ex(self):
else:
obj = cls.__new__(cls, *args, **kwargs)
self.append(obj)


try:
Unpickler.dispatch[pkl.NEWOBJ_EX[0]] = load_newobj_ex
except:
Expand Down
8 changes: 3 additions & 5 deletions pandas/computation/engines.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Engine classes for :func:`~pandas.eval`
"""

# flake8: noqa
Engine classes for :func:`~pandas.eval`
"""

import abc

from pandas import compat
from pandas.compat import DeepChainMap, map
import pandas.core.common as com
from pandas.compat import map
import pandas.formats.printing as printing
from pandas.computation.align import _align, _reconstruct_object
from pandas.computation.ops import (UndefinedVariableError,
Expand Down
8 changes: 4 additions & 4 deletions pandas/util/clipboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
"""
__version__ = '1.5.27'

# flake8: noqa

import platform
import os
import subprocess
Expand Down Expand Up @@ -62,14 +60,16 @@ def determine_clipboard():
if HAS_DISPLAY:
# Determine which command/module is installed, if any.
try:
import gtk # check if gtk is installed
# Check if gtk is installed
import gtk # noqa
except ImportError:
pass
else:
return init_gtk_clipboard()

try:
import PyQt4 # check if PyQt4 is installed
# Check if PyQt4 is installed
import PyQt4 # noqa
except ImportError:
pass
else:
Expand Down
4 changes: 1 addition & 3 deletions pandas/util/clipboard/clipboards.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# flake8: noqa

import sys
import subprocess
from .exceptions import PyperclipException
Expand All @@ -8,7 +6,7 @@
Pyperclip could not find a copy/paste mechanism for your system.
For more information, please visit https://pyperclip.readthedocs.org """
PY2 = sys.version_info[0] == 2
text_type = unicode if PY2 else str
text_type = unicode if PY2 else str # noqa


def init_osx_clipboard():
Expand Down
1 change: 0 additions & 1 deletion pandas/util/clipboard/windows.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# flake8: noqa
"""
This module implements clipboard handling on Windows using ctypes.
"""
Expand Down