Skip to content

BLD: Run flake8 check on Cython files in pre-commit #30847

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 6 commits into from
Feb 12, 2020
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
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ repos:
- id: flake8
language: python_venv
additional_dependencies: [flake8-comprehensions>=3.1.0]
- id: flake8
name: flake8-pyx
language: python_venv
files: \.(pyx|pxd)$
types:
- file
args: [--append-config=flake8/cython.cfg]
- id: flake8
name: flake8-pxd
language: python_venv
files: \.pxi\.in$
types:
- file
args: [--append-config=flake8/cython-template.cfg]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
Expand Down
8 changes: 4 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
flake8 --format="$FLAKE8_FORMAT" .
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting .pyx code' ; echo $MSG
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
MSG='Linting .pyx and .pxd code' ; echo $MSG
flake8 --format="$FLAKE8_FORMAT" pandas --append-config=flake8/cython.cfg
RET=$(($RET + $?)) ; echo $MSG "DONE"

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

echo "flake8-rst --version"
Expand Down
4 changes: 4 additions & 0 deletions flake8/cython-template.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
filename = *.pxi.in
select = E501,E302,E203,E111,E114,E221,E303,E231,E126,F403

3 changes: 3 additions & 0 deletions flake8/cython.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
filename = *.pyx,*.pxd
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
2 changes: 1 addition & 1 deletion pandas/_libs/sparse_op_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ cdef inline tuple int_op_{{opname}}_{{dtype}}({{dtype}}_t[:] x_,
{{dtype}}_t yfill):
cdef:
IntIndex out_index
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
Py_ssize_t xi = 0, yi = 0, out_i = 0 # fp buf indices
int32_t xloc, yloc
int32_t[:] xindices, yindices, out_indices
{{dtype}}_t[:] x, y
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/util.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cdef extern from "numpy/ndarrayobject.h":
bint PyArray_IsIntegerScalar(obj) nogil
bint PyArray_Check(obj) nogil

cdef extern from "numpy/npy_common.h":
cdef extern from "numpy/npy_common.h":
int64_t NPY_MIN_INT64


Expand Down
5 changes: 3 additions & 2 deletions web/pandas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
import time
import typing

import feedparser
import jinja2
import markdown
import requests
import yaml

import feedparser
import markdown


class Preprocessors:
"""
Expand Down