Skip to content

Commit 99f6178

Browse files
authored
CLN: tighten flake8/cython.cfg (#44260)
1 parent f313779 commit 99f6178

File tree

7 files changed

+30
-35
lines changed

7 files changed

+30
-35
lines changed

flake8/cython.cfg

-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,5 @@ extend_ignore=
99
E226,
1010
# missing whitespace around bitwise or shift operator
1111
E227,
12-
# ambiguous variable name (# FIXME maybe this one can be fixed)
13-
E741,
1412
# invalid syntax
1513
E999,
16-
# invalid escape sequence (# FIXME maybe this one can be fixed)
17-
W605,

pandas/_libs/algos.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ cdef inline numeric_t kth_smallest_c(numeric_t* arr, Py_ssize_t k, Py_ssize_t n)
259259
in groupby.pyx
260260
"""
261261
cdef:
262-
Py_ssize_t i, j, l, m
262+
Py_ssize_t i, j, left, m
263263
numeric_t x
264264

265-
l = 0
265+
left = 0
266266
m = n - 1
267267

268-
while l < m:
268+
while left < m:
269269
x = arr[k]
270-
i = l
270+
i = left
271271
j = m
272272

273273
while 1:
@@ -284,7 +284,7 @@ cdef inline numeric_t kth_smallest_c(numeric_t* arr, Py_ssize_t k, Py_ssize_t n)
284284
break
285285

286286
if j < k:
287-
l = i
287+
left = i
288288
if k < i:
289289
m = j
290290
return arr[k]

pandas/_libs/hashing.pyx

+2-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def hash_object_array(
5252
mixed array types will raise TypeError.
5353
"""
5454
cdef:
55-
Py_ssize_t i, l, n
55+
Py_ssize_t i, n
5656
uint64_t[:] result
5757
bytes data, k
5858
uint8_t *kb
@@ -97,8 +97,7 @@ def hash_object_array(
9797
"must be string or null"
9898
)
9999

100-
l = len(data)
101-
lens[i] = l
100+
lens[i] = len(data)
102101
cdata = data
103102

104103
# keep the references alive through the end of the

pandas/_libs/internals.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ cdef class BlockPlacement:
179179
cdef BlockPlacement iadd(self, other):
180180
cdef:
181181
slice s = self._ensure_has_slice()
182-
Py_ssize_t other_int, start, stop, step, l
182+
Py_ssize_t other_int, start, stop, step
183183

184184
if is_integer_object(other) and s is not None:
185185
other_int = <Py_ssize_t>other
@@ -188,7 +188,7 @@ cdef class BlockPlacement:
188188
# BlockPlacement is treated as immutable
189189
return self
190190

191-
start, stop, step, l = slice_get_indices_ex(s)
191+
start, stop, step, _ = slice_get_indices_ex(s)
192192
start += other_int
193193
stop += other_int
194194

@@ -226,14 +226,14 @@ cdef class BlockPlacement:
226226
"""
227227
cdef:
228228
slice nv, s = self._ensure_has_slice()
229-
Py_ssize_t other_int, start, stop, step, l
229+
Py_ssize_t other_int, start, stop, step
230230
ndarray[intp_t, ndim=1] newarr
231231

232232
if s is not None:
233233
# see if we are either all-above or all-below, each of which
234234
# have fastpaths available.
235235

236-
start, stop, step, l = slice_get_indices_ex(s)
236+
start, stop, step, _ = slice_get_indices_ex(s)
237237

238238
if start < loc and stop <= loc:
239239
# We are entirely below, nothing to increment

pandas/_libs/tslibs/parsing.pyx

+6-6
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,12 @@ class _timelex:
808808
# TODO: Change \s --> \s+ (this doesn't match existing behavior)
809809
# TODO: change the punctuation block to punc+ (does not match existing)
810810
# TODO: can we merge the two digit patterns?
811-
tokens = re.findall('\s|'
812-
'(?<![\.\d])\d+\.\d+(?![\.\d])'
813-
'|\d+'
814-
'|[a-zA-Z]+'
815-
'|[\./:]+'
816-
'|[^\da-zA-Z\./:\s]+', stream)
811+
tokens = re.findall(r"\s|"
812+
r"(?<![\.\d])\d+\.\d+(?![\.\d])"
813+
r"|\d+"
814+
r"|[a-zA-Z]+"
815+
r"|[\./:]+"
816+
r"|[^\da-zA-Z\./:\s]+", stream)
817817

818818
# Re-combine token tuples of the form ["59", ",", "456"] because
819819
# in this context the "," is treated as a decimal

pandas/_libs/tslibs/period.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -983,14 +983,14 @@ def periodarr_to_dt64arr(const int64_t[:] periodarr, int freq):
983983
"""
984984
cdef:
985985
int64_t[:] out
986-
Py_ssize_t i, l
986+
Py_ssize_t i, N
987987

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

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

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

22502250
def strftime(self, fmt: str) -> str:
2251-
"""
2251+
r"""
22522252
Returns the string representation of the :class:`Period`, depending
22532253
on the selected ``fmt``. ``fmt`` must be a string
22542254
containing one or several directives. The method recognizes the same

pandas/_libs/writers.pyx

+8-8
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ def max_len_string_array(pandas_string[:] arr) -> Py_ssize_t:
125125
Return the maximum size of elements in a 1-dim string array.
126126
"""
127127
cdef:
128-
Py_ssize_t i, m = 0, l = 0, length = arr.shape[0]
128+
Py_ssize_t i, m = 0, wlen = 0, length = arr.shape[0]
129129
pandas_string val
130130

131131
for i in range(length):
132132
val = arr[i]
133-
l = word_len(val)
133+
wlen = word_len(val)
134134

135-
if l > m:
136-
m = l
135+
if wlen > m:
136+
m = wlen
137137

138138
return m
139139

@@ -143,14 +143,14 @@ cpdef inline Py_ssize_t word_len(object val):
143143
Return the maximum length of a string or bytes value.
144144
"""
145145
cdef:
146-
Py_ssize_t l = 0
146+
Py_ssize_t wlen = 0
147147

148148
if isinstance(val, str):
149-
l = PyUnicode_GET_LENGTH(val)
149+
wlen = PyUnicode_GET_LENGTH(val)
150150
elif isinstance(val, bytes):
151-
l = PyBytes_GET_SIZE(val)
151+
wlen = PyBytes_GET_SIZE(val)
152152

153-
return l
153+
return wlen
154154

155155
# ------------------------------------------------------------------
156156
# PyTables Helpers

0 commit comments

Comments
 (0)