Skip to content

Commit 012a6a3

Browse files
authored
BLD: Run flake8 check on Cython files in pre-commit (#30847)
1 parent dd03c19 commit 012a6a3

7 files changed

+30
-8
lines changed

.pre-commit-config.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ repos:
1010
- id: flake8
1111
language: python_venv
1212
additional_dependencies: [flake8-comprehensions>=3.1.0]
13+
- id: flake8
14+
name: flake8-pyx
15+
language: python_venv
16+
files: \.(pyx|pxd)$
17+
types:
18+
- file
19+
args: [--append-config=flake8/cython.cfg]
20+
- id: flake8
21+
name: flake8-pxd
22+
language: python_venv
23+
files: \.pxi\.in$
24+
types:
25+
- file
26+
args: [--append-config=flake8/cython-template.cfg]
1327
- repo: https://github.com/pre-commit/mirrors-isort
1428
rev: v4.3.21
1529
hooks:

ci/code_checks.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
6565
flake8 --format="$FLAKE8_FORMAT" .
6666
RET=$(($RET + $?)) ; echo $MSG "DONE"
6767

68-
MSG='Linting .pyx code' ; echo $MSG
69-
flake8 --format="$FLAKE8_FORMAT" pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
68+
MSG='Linting .pyx and .pxd code' ; echo $MSG
69+
flake8 --format="$FLAKE8_FORMAT" pandas --append-config=flake8/cython.cfg
7070
RET=$(($RET + $?)) ; echo $MSG "DONE"
7171

72-
MSG='Linting .pxd and .pxi.in' ; echo $MSG
73-
flake8 --format="$FLAKE8_FORMAT" pandas/_libs --filename=*.pxi.in,*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
72+
MSG='Linting .pxi.in' ; echo $MSG
73+
flake8 --format="$FLAKE8_FORMAT" pandas/_libs --append-config=flake8/cython-template.cfg
7474
RET=$(($RET + $?)) ; echo $MSG "DONE"
7575

7676
echo "flake8-rst --version"

flake8/cython-template.cfg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
filename = *.pxi.in
3+
select = E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
4+

flake8/cython.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
filename = *.pyx,*.pxd
3+
select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411

pandas/_libs/sparse_op_helper.pxi.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ cdef inline tuple int_op_{{opname}}_{{dtype}}({{dtype}}_t[:] x_,
235235
{{dtype}}_t yfill):
236236
cdef:
237237
IntIndex out_index
238-
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
238+
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
239239
int32_t xloc, yloc
240240
int32_t[:] xindices, yindices, out_indices
241241
{{dtype}}_t[:] x, y

pandas/_libs/tslibs/util.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ cdef extern from "numpy/ndarrayobject.h":
4242
bint PyArray_IsIntegerScalar(obj) nogil
4343
bint PyArray_Check(obj) nogil
4444

45-
cdef extern from "numpy/npy_common.h":
45+
cdef extern from "numpy/npy_common.h":
4646
int64_t NPY_MIN_INT64
4747

4848

web/pandas_web.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@
3434
import time
3535
import typing
3636

37-
import feedparser
3837
import jinja2
39-
import markdown
4038
import requests
4139
import yaml
4240

41+
import feedparser
42+
import markdown
43+
4344

4445
class Preprocessors:
4546
"""

0 commit comments

Comments
 (0)