Skip to content

Commit

Permalink
Unpin pycodestyle (#25789)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd authored and jreback committed Mar 20, 2019
1 parent a70eb0f commit 05780f8
Show file tree
Hide file tree
Showing 29 changed files with 98 additions and 71 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:
- hypothesis>=3.82
- isort
- moto
- pycodestyle=2.4
- pycodestyle
- pytest>=4.0.2
- pytest-mock
- sphinx
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# flake8: noqa

from .tslibs import (
iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime, Period)
iNaT, NaT, NaTType, Timestamp, Timedelta, OutOfBoundsDatetime, Period)
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# flake8: noqa

from .conversion import normalize_date, localize_pydatetime, tz_convert_single
from .nattype import NaT, iNaT, is_null_datetimelike
from .nattype import NaT, NaTType, iNaT, is_null_datetimelike
from .np_datetime import OutOfBoundsDatetime
from .period import Period, IncompatibleFrequency
from .timestamps import Timestamp
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class NaTType(_NaT):
.. versionadded:: 0.23.0
""")
day_name = _make_nan_func('day_name', # noqa:E128
day_name = _make_nan_func('day_name', # noqa:E128
"""
Return the day name of the Timestamp with specified locale.
Expand Down
6 changes: 5 additions & 1 deletion pandas/core/arrays/array_.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from typing import Optional, Sequence, Union

import numpy as np

from pandas._libs import lib, tslibs

from pandas.core.dtypes.common import (
is_datetime64_ns_dtype, is_extension_array_dtype, is_timedelta64_ns_dtype)
from pandas.core.dtypes.dtypes import registry
from pandas.core.dtypes.dtypes import ExtensionDtype, registry

from pandas import compat

Expand Down
8 changes: 5 additions & 3 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
without warning.
"""
import operator
from typing import Any, Callable, Optional, Sequence, Tuple, Union

import numpy as np

Expand All @@ -15,6 +16,7 @@
from pandas.util._decorators import Appender, Substitution

from pandas.core.dtypes.common import is_list_like
from pandas.core.dtypes.dtypes import ExtensionDtype
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
from pandas.core.dtypes.missing import isna

Expand Down Expand Up @@ -365,7 +367,7 @@ def isna(self):
raise AbstractMethodError(self)

def _values_for_argsort(self):
# type: () -> ndarray
# type: () -> np.ndarray
"""
Return values for sorting.
Expand Down Expand Up @@ -597,7 +599,7 @@ def searchsorted(self, value, side="left", sorter=None):
return arr.searchsorted(value, side=side, sorter=sorter)

def _values_for_factorize(self):
# type: () -> Tuple[ndarray, Any]
# type: () -> Tuple[np.ndarray, Any]
"""
Return an array and missing value suitable for factorization.
Expand All @@ -622,7 +624,7 @@ def _values_for_factorize(self):
return self.astype(object), np.nan

def factorize(self, na_sentinel=-1):
# type: (int) -> Tuple[ndarray, ExtensionArray]
# type: (int) -> Tuple[np.ndarray, ExtensionArray]
"""
Encode the extension array as an enumerated type.
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
import operator
from typing import Any, Sequence, Tuple, Union
import warnings

import numpy as np

from pandas._libs import NaT, algos, iNaT, lib
from pandas._libs import NaT, NaTType, Timestamp, algos, iNaT, lib
from pandas._libs.tslibs.period import (
DIFFERENT_FREQ, IncompatibleFrequency, Period)
from pandas._libs.tslibs.timedeltas import Timedelta, delta_to_nanoseconds
Expand Down Expand Up @@ -350,7 +351,7 @@ def __iter__(self):

@property
def asi8(self):
# type: () -> ndarray
# type: () -> np.ndarray
"""
Integer representation of the values.
Expand Down Expand Up @@ -461,10 +462,10 @@ def __getitem__(self, key):
def __setitem__(
self,
key, # type: Union[int, Sequence[int], Sequence[bool], slice]
value, # type: Union[NaTType, Scalar, Sequence[Scalar]]
value, # type: Union[NaTType, Any, Sequence[Any]]
):
# type: (...) -> None
# I'm fudging the types a bit here. The "Scalar" above really depends
# I'm fudging the types a bit here. "Any" above really depends
# on type(self). For PeriodArray, it's Period (or stuff coercible
# to a period in from_sequence). For DatetimeArray, it's Timestamp...
# I don't know if mypy can do that, possibly with Generics.
Expand Down
1 change: 1 addition & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from datetime import datetime, time, timedelta
import textwrap
from typing import Union
import warnings

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def value_counts(self, dropna=True):
return Series(array, index=index)

def _values_for_argsort(self):
# type: () -> ndarray
# type: () -> np.ndarray
"""Return values for sorting.
Returns
Expand Down
12 changes: 8 additions & 4 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from datetime import timedelta
import operator
from typing import Any, Callable, Optional, Sequence, Union

import numpy as np

from pandas._libs.tslibs import (
NaT, frequencies as libfrequencies, iNaT, period as libperiod)
NaT, NaTType, frequencies as libfrequencies, iNaT, period as libperiod)
from pandas._libs.tslibs.fields import isleapyear_arr
from pandas._libs.tslibs.period import (
DIFFERENT_FREQ, IncompatibleFrequency, Period, get_period_field_arr,
Expand All @@ -23,7 +24,7 @@
from pandas.core.dtypes.missing import isna, notna

import pandas.core.algorithms as algos
from pandas.core.arrays import datetimelike as dtl
from pandas.core.arrays import ExtensionArray, datetimelike as dtl
import pandas.core.common as com

from pandas.tseries import frequencies
Expand Down Expand Up @@ -536,11 +537,14 @@ def _sub_period(self, other):
@Appender(dtl.DatetimeLikeArrayMixin._addsub_int_array.__doc__)
def _addsub_int_array(
self,
other, # type: Union[Index, ExtensionArray, np.ndarray[int]]
op # type: Callable[Any, Any]
other, # type: Union[ExtensionArray, np.ndarray[int]]
op # type: Callable[Any, Any]
):
# type: (...) -> PeriodArray

# TODO: ABCIndexClass is a valid type for other but had to be excluded
# due to length of Py2 compatability comment; add back in once migrated
# to Py3 syntax
assert op in [operator.add, operator.sub]
if op is operator.sub:
other = -other
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/arrays/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import numbers
import operator
import re
from typing import Any, Callable, Union
import warnings

import numpy as np

from pandas._libs import index as libindex, lib
import pandas._libs.sparse as splib
from pandas._libs.sparse import BlockIndex, IntIndex
from pandas._libs.sparse import BlockIndex, IntIndex, SparseIndex
from pandas._libs.tslibs import NaT
import pandas.compat as compat
from pandas.compat.numpy import function as nv
Expand Down Expand Up @@ -372,7 +373,7 @@ def _subtype_with_str(self):


def _get_fill(arr):
# type: (SparseArray) -> ndarray
# type: (SparseArray) -> np.ndarray
"""
Create a 0-dim ndarray containing the fill value
Expand Down
1 change: 1 addition & 0 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from pandas.core import algorithms, common as com
from pandas.core.accessor import DirNamesMixin
from pandas.core.arrays import ExtensionArray
import pandas.core.nanops as nanops

_shared_docs = dict()
Expand Down
1 change: 1 addition & 0 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from datetime import datetime, timedelta
from functools import partial
import inspect
from typing import Any

import numpy as np

Expand Down
4 changes: 3 additions & 1 deletion pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Extend pandas with custom array types"""
from typing import List, Optional, Type

import numpy as np

from pandas.errors import AbstractMethodError
Expand Down Expand Up @@ -211,7 +213,7 @@ def __str__(self):

@property
def type(self):
# type: () -> type
# type: () -> Type
"""
The scalar type for the array, e.g. ``int``
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def construct_from_string(cls, string):

if (string.lower() == 'interval' or
cls._match.search(string) is not None):
return cls(string)
return cls(string)

msg = ('Incorrectly formatted string passed to constructor. '
'Valid formats include Interval or Interval[dtype] '
Expand Down
1 change: 1 addition & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
import warnings
from textwrap import dedent
from typing import List, Union

import numpy as np
import numpy.ma as ma
Expand Down
11 changes: 6 additions & 5 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class providing the base-class of operations.
import datetime
from functools import partial, wraps
import types
from typing import Optional, Type
import warnings

import numpy as np
Expand Down Expand Up @@ -1040,7 +1041,7 @@ def _bool_agg(self, val_test, skipna):
"""

def objs_to_bool(vals):
# type: (np.ndarray) -> (np.ndarray, typing.Type)
# type: (np.ndarray) -> (np.ndarray, Type)
if is_object_dtype(vals):
vals = np.array([bool(x) for x in vals])
else:
Expand All @@ -1049,7 +1050,7 @@ def objs_to_bool(vals):
return vals.view(np.uint8), np.bool

def result_to_bool(result, inference):
# type: (np.ndarray, typing.Type) -> np.ndarray
# type: (np.ndarray, Type) -> np.ndarray
return result.astype(inference, copy=False)

return self._get_cythonized_result('group_any_all', self.grouper,
Expand Down Expand Up @@ -1738,7 +1739,7 @@ def quantile(self, q=0.5, interpolation='linear'):
"""

def pre_processor(vals):
# type: (np.ndarray) -> (np.ndarray, Optional[typing.Type])
# type: (np.ndarray) -> (np.ndarray, Optional[Type])
if is_object_dtype(vals):
raise TypeError("'quantile' cannot be performed against "
"'object' dtypes!")
Expand All @@ -1753,7 +1754,7 @@ def pre_processor(vals):
return vals, inference

def post_processor(vals, inference):
# type: (np.ndarray, Optional[typing.Type]) -> np.ndarray
# type: (np.ndarray, Optional[Type]) -> np.ndarray
if inference:
# Check for edge case
if not (is_integer_dtype(inference) and
Expand Down Expand Up @@ -2016,7 +2017,7 @@ def _get_cythonized_result(self, how, grouper, aggregate=False,
Function to be applied to result of Cython function. Should accept
an array of values as the first argument and type inferences as its
second argument, i.e. the signature should be
(ndarray, typing.Type).
(ndarray, Type).
**kwargs : dict
Extra arguments to be passed back to Cython funcs
Expand Down
1 change: 1 addition & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime, timedelta
import operator
from textwrap import dedent
from typing import Union
import warnings

import numpy as np
Expand Down
8 changes: 6 additions & 2 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import inspect
import re
from typing import Any, List
import warnings

import numpy as np
Expand Down Expand Up @@ -1826,8 +1827,11 @@ def interpolate(self, method='pad', axis=0, inplace=False, limit=None,
limit=limit),
placement=self.mgr_locs)

def shift(self, periods, axis=0, fill_value=None):
# type: (int, Optional[BlockPlacement], Any) -> List[ExtensionBlock]
def shift(self,
periods, # type: int
axis=0, # type: libinternals.BlockPlacement
fill_value=None): # type: Any
# type: (...) -> List[ExtensionBlock]
"""
Shift the block by `periods`.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import itertools
import operator
import re
from typing import List, Optional, Union

import numpy as np

Expand All @@ -18,6 +19,7 @@
_NS_DTYPE, is_datetimelike_v_numeric, is_extension_array_dtype,
is_extension_type, is_list_like, is_numeric_v_string_like, is_scalar)
import pandas.core.dtypes.concat as _concat
from pandas.core.dtypes.dtypes import ExtensionDtype
from pandas.core.dtypes.generic import ABCExtensionArray, ABCSeries
from pandas.core.dtypes.missing import isna

Expand Down
1 change: 0 additions & 1 deletion pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ def _chk_truncate(self):
max_rows = self.max_rows

if max_cols == 0 or max_rows == 0: # assume we are in the terminal
# (why else = 0)
(w, h) = get_terminal_size()
self.w = w
self.h = h
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/frame/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def test_set_index_pass_arrays_duplicate(self, frame_of_index_cols, drop,
# need to adapt first drop for case that both keys are 'A' --
# cannot drop the same column twice;
# use "is" because == would give ambiguous Boolean error for containers
first_drop = False if (keys[0] is 'A' and keys[1] is 'A') else drop
first_drop = False if (
keys[0] is 'A' and keys[1] is 'A') else drop # noqa: F632

# to test against already-tested behaviour, we add sequentially,
# hence second append always True; must wrap keys in list, otherwise
Expand Down Expand Up @@ -1272,7 +1273,7 @@ def test_rename_axis_style_raises(self):
df.rename(id, mapper=id)

def test_reindex_api_equivalence(self):
# equivalence of the labels/axis and index/columns API's
# equivalence of the labels/axis and index/columns API's
df = DataFrame([[1, 2, 3], [3, 4, 5], [5, 6, 7]],
index=['a', 'b', 'c'],
columns=['d', 'e', 'f'])
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def test_apply_issues():
# GH 5788
# GH 5788

s = """2011.05.16,00:00,1.40893
2011.05.16,01:00,1.40760
Expand Down
Loading

0 comments on commit 05780f8

Please sign in to comment.