Skip to content

CLN: tighten flake8/cython.cfg #44260

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

Merged
merged 1 commit into from
Nov 1, 2021
Merged
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
4 changes: 0 additions & 4 deletions flake8/cython.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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,
10 changes: 5 additions & 5 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]
Expand Down
5 changes: 2 additions & 3 deletions pandas/_libs/hashing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pandas/_libs/internals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <Py_ssize_t>other
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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|'
'(?<![\.\d])\d+\.\d+(?![\.\d])'
'|\d+'
'|[a-zA-Z]+'
'|[\./:]+'
'|[^\da-zA-Z\./:\s]+', stream)
tokens = re.findall(r"\s|"
r"(?<![\.\d])\d+\.\d+(?![\.\d])"
r"|\d+"
r"|[a-zA-Z]+"
r"|[\./:]+"
r"|[^\da-zA-Z\./:\s]+", stream)

# Re-combine token tuples of the form ["59", ",", "456"] because
# in this context the "," is treated as a decimal
Expand Down
10 changes: 5 additions & 5 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -983,14 +983,14 @@ def periodarr_to_dt64arr(const int64_t[:] periodarr, int freq):
"""
cdef:
int64_t[:] out
Py_ssize_t i, l
Py_ssize_t i, N

if freq < 6000: # i.e. FR_DAY, hard-code to avoid need to cast
l = len(periodarr)
out = np.empty(l, dtype="i8")
N = len(periodarr)
out = np.empty(N, dtype="i8")

# We get here with freqs that do not correspond to a datetime64 unit
for i in range(l):
for i in range(N):
out[i] = period_ordinal_to_dt64(periodarr[i], freq)

return out.base # .base to access underlying np.ndarray
Expand Down Expand Up @@ -2248,7 +2248,7 @@ cdef class _Period(PeriodMixin):
return (Period, object_state)

def strftime(self, fmt: str) -> 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
Expand Down
16 changes: 8 additions & 8 deletions pandas/_libs/writers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down