From 66625fbc98841168999bf808f2ecd33c36bfaa61 Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 31 Oct 2021 16:49:47 -0700 Subject: [PATCH] CLN: tighten flake8/cython.cfg --- flake8/cython.cfg | 4 ---- pandas/_libs/algos.pyx | 10 +++++----- pandas/_libs/hashing.pyx | 5 ++--- pandas/_libs/internals.pyx | 8 ++++---- pandas/_libs/tslibs/parsing.pyx | 12 ++++++------ pandas/_libs/tslibs/period.pyx | 10 +++++----- pandas/_libs/writers.pyx | 16 ++++++++-------- 7 files changed, 30 insertions(+), 35 deletions(-) diff --git a/flake8/cython.cfg b/flake8/cython.cfg index a9584ad2e0994..bf1f41647b34e 100644 --- a/flake8/cython.cfg +++ b/flake8/cython.cfg @@ -9,9 +9,5 @@ extend_ignore= E226, # missing whitespace around bitwise or shift operator E227, - # ambiguous variable name (# FIXME maybe this one can be fixed) - E741, # invalid syntax E999, - # invalid escape sequence (# FIXME maybe this one can be fixed) - W605, diff --git a/pandas/_libs/algos.pyx b/pandas/_libs/algos.pyx index 68c09f83e1cdf..3d099a53163bc 100644 --- a/pandas/_libs/algos.pyx +++ b/pandas/_libs/algos.pyx @@ -259,15 +259,15 @@ cdef inline numeric_t kth_smallest_c(numeric_t* arr, Py_ssize_t k, Py_ssize_t n) in groupby.pyx """ cdef: - Py_ssize_t i, j, l, m + Py_ssize_t i, j, left, m numeric_t x - l = 0 + left = 0 m = n - 1 - while l < m: + while left < m: x = arr[k] - i = l + i = left j = m while 1: @@ -284,7 +284,7 @@ cdef inline numeric_t kth_smallest_c(numeric_t* arr, Py_ssize_t k, Py_ssize_t n) break if j < k: - l = i + left = i if k < i: m = j return arr[k] diff --git a/pandas/_libs/hashing.pyx b/pandas/_libs/hashing.pyx index 75eee4d432637..39caf04ddf2f8 100644 --- a/pandas/_libs/hashing.pyx +++ b/pandas/_libs/hashing.pyx @@ -52,7 +52,7 @@ def hash_object_array( mixed array types will raise TypeError. """ cdef: - Py_ssize_t i, l, n + Py_ssize_t i, n uint64_t[:] result bytes data, k uint8_t *kb @@ -97,8 +97,7 @@ def hash_object_array( "must be string or null" ) - l = len(data) - lens[i] = l + lens[i] = len(data) cdata = data # keep the references alive through the end of the diff --git a/pandas/_libs/internals.pyx b/pandas/_libs/internals.pyx index 957432df20395..ac423ef6c0ca2 100644 --- a/pandas/_libs/internals.pyx +++ b/pandas/_libs/internals.pyx @@ -179,7 +179,7 @@ cdef class BlockPlacement: cdef BlockPlacement iadd(self, other): cdef: slice s = self._ensure_has_slice() - Py_ssize_t other_int, start, stop, step, l + Py_ssize_t other_int, start, stop, step if is_integer_object(other) and s is not None: other_int = other @@ -188,7 +188,7 @@ cdef class BlockPlacement: # BlockPlacement is treated as immutable return self - start, stop, step, l = slice_get_indices_ex(s) + start, stop, step, _ = slice_get_indices_ex(s) start += other_int stop += other_int @@ -226,14 +226,14 @@ cdef class BlockPlacement: """ cdef: slice nv, s = self._ensure_has_slice() - Py_ssize_t other_int, start, stop, step, l + Py_ssize_t other_int, start, stop, step ndarray[intp_t, ndim=1] newarr if s is not None: # see if we are either all-above or all-below, each of which # have fastpaths available. - start, stop, step, l = slice_get_indices_ex(s) + start, stop, step, _ = slice_get_indices_ex(s) if start < loc and stop <= loc: # We are entirely below, nothing to increment diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index b8f957a4c2ea8..f2b480642e083 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -808,12 +808,12 @@ class _timelex: # TODO: Change \s --> \s+ (this doesn't match existing behavior) # TODO: change the punctuation block to punc+ (does not match existing) # TODO: can we merge the two digit patterns? - tokens = re.findall('\s|' - '(? str: - """ + r""" Returns the string representation of the :class:`Period`, depending on the selected ``fmt``. ``fmt`` must be a string containing one or several directives. The method recognizes the same diff --git a/pandas/_libs/writers.pyx b/pandas/_libs/writers.pyx index 79f551c9ebf6f..46f04cf8e15b3 100644 --- a/pandas/_libs/writers.pyx +++ b/pandas/_libs/writers.pyx @@ -125,15 +125,15 @@ def max_len_string_array(pandas_string[:] arr) -> Py_ssize_t: Return the maximum size of elements in a 1-dim string array. """ cdef: - Py_ssize_t i, m = 0, l = 0, length = arr.shape[0] + Py_ssize_t i, m = 0, wlen = 0, length = arr.shape[0] pandas_string val for i in range(length): val = arr[i] - l = word_len(val) + wlen = word_len(val) - if l > m: - m = l + if wlen > m: + m = wlen return m @@ -143,14 +143,14 @@ cpdef inline Py_ssize_t word_len(object val): Return the maximum length of a string or bytes value. """ cdef: - Py_ssize_t l = 0 + Py_ssize_t wlen = 0 if isinstance(val, str): - l = PyUnicode_GET_LENGTH(val) + wlen = PyUnicode_GET_LENGTH(val) elif isinstance(val, bytes): - l = PyBytes_GET_SIZE(val) + wlen = PyBytes_GET_SIZE(val) - return l + return wlen # ------------------------------------------------------------------ # PyTables Helpers