From 242a700aa519ecdfbcce7a71c6127e58fc30810c Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Thu, 9 Jan 2020 14:26:07 +0100 Subject: [PATCH 1/6] BLD: Run flake8 check on Cython files in pre-commit --- .flake8.cython | 3 +++ .flake8.cython-header | 4 ++++ .pre-commit-config.yaml | 14 ++++++++++++++ ci/code_checks.sh | 4 ++-- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .flake8.cython create mode 100644 .flake8.cython-header diff --git a/.flake8.cython b/.flake8.cython new file mode 100644 index 0000000000000..385efcfed714c --- /dev/null +++ b/.flake8.cython @@ -0,0 +1,3 @@ +[flake8] +filename = *.pyx,*.pxd,*.pxi +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 diff --git a/.flake8.cython-header b/.flake8.cython-header new file mode 100644 index 0000000000000..3129d344feae6 --- /dev/null +++ b/.flake8.cython-header @@ -0,0 +1,4 @@ +[flake8] +filename = *.pxd,*.pxi,*.pxi.in +select = E501,E302,E203,E111,E114,E221,E303,E231,E126,F403 + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 139b9e31df46c..63b6f1d8f6c27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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$ + types: + - file + args: [--append-config=.flake8.cython] + - id: flake8 + name: flake8-pxd + language: python_venv + files: \.(pxd|pxi\.in)$ + types: + - file + args: [--append-config=.flake8.cython-header] - repo: https://github.com/pre-commit/mirrors-isort rev: v4.3.21 hooks: diff --git a/ci/code_checks.sh b/ci/code_checks.sh index fdc9fef5d7f77..f36c2888d45d4 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -66,11 +66,11 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then 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 + flake8 --format="$FLAKE8_FORMAT" pandas --append-config=.flake8.cython 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 + flake8 --format="$FLAKE8_FORMAT" pandas/_libs --append-config=.flake8.cython-header RET=$(($RET + $?)) ; echo $MSG "DONE" echo "flake8-rst --version" From 0eeff1ce0c6c318c9404f87038ea8321cde65594 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Thu, 9 Jan 2020 18:27:15 +0100 Subject: [PATCH 2/6] Only lint pyx with .flake8.cython --- .flake8.cython | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8.cython b/.flake8.cython index 385efcfed714c..f883aad726623 100644 --- a/.flake8.cython +++ b/.flake8.cython @@ -1,3 +1,3 @@ [flake8] -filename = *.pyx,*.pxd,*.pxi +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 From a3feff86e3b7dd523a9ddb1e4c4366cdf44a9b25 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Thu, 9 Jan 2020 19:11:15 +0100 Subject: [PATCH 3/6] Don't check generated pxi files --- .flake8.cython-header | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8.cython-header b/.flake8.cython-header index 3129d344feae6..7f6de31eb315c 100644 --- a/.flake8.cython-header +++ b/.flake8.cython-header @@ -1,4 +1,4 @@ [flake8] -filename = *.pxd,*.pxi,*.pxi.in +filename = *.pxd,*.pxi.in select = E501,E302,E203,E111,E114,E221,E303,E231,E126,F403 From f9a7bf1ba2cdd0e0a535ccdf54bc1c2e78614e52 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 12 Jan 2020 12:56:58 +0100 Subject: [PATCH 4/6] Move flake8 config into a separate folder --- .pre-commit-config.yaml | 4 ++-- ci/code_checks.sh | 4 ++-- .flake8.cython-header => flake8/cython-header.cfg | 0 .flake8.cython => flake8/cython.cfg | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename .flake8.cython-header => flake8/cython-header.cfg (100%) rename .flake8.cython => flake8/cython.cfg (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 63b6f1d8f6c27..deea23fe99c30 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,14 +16,14 @@ repos: files: \.pyx$ types: - file - args: [--append-config=.flake8.cython] + args: [--append-config=flake8/cython.cfg] - id: flake8 name: flake8-pxd language: python_venv files: \.(pxd|pxi\.in)$ types: - file - args: [--append-config=.flake8.cython-header] + args: [--append-config=flake8/cython-header.cfg] - repo: https://github.com/pre-commit/mirrors-isort rev: v4.3.21 hooks: diff --git a/ci/code_checks.sh b/ci/code_checks.sh index f36c2888d45d4..c8f0a9ae9e48d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -66,11 +66,11 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then RET=$(($RET + $?)) ; echo $MSG "DONE" MSG='Linting .pyx code' ; echo $MSG - flake8 --format="$FLAKE8_FORMAT" pandas --append-config=.flake8.cython + 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 --append-config=.flake8.cython-header + flake8 --format="$FLAKE8_FORMAT" pandas/_libs --append-config=flake8/cython-header.cfg RET=$(($RET + $?)) ; echo $MSG "DONE" echo "flake8-rst --version" diff --git a/.flake8.cython-header b/flake8/cython-header.cfg similarity index 100% rename from .flake8.cython-header rename to flake8/cython-header.cfg diff --git a/.flake8.cython b/flake8/cython.cfg similarity index 100% rename from .flake8.cython rename to flake8/cython.cfg From 830f5e1f73a51a557871357ff407d2cebb7dd036 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Mon, 10 Feb 2020 22:20:07 +0100 Subject: [PATCH 5/6] Stricter flake8 rules for pxd --- .pre-commit-config.yaml | 6 +++--- ci/code_checks.sh | 6 +++--- flake8/{cython-header.cfg => cython-template.cfg} | 2 +- flake8/cython.cfg | 2 +- pandas/_libs/sparse_op_helper.pxi.in | 2 +- pandas/_libs/tslibs/util.pxd | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) rename flake8/{cython-header.cfg => cython-template.cfg} (72%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index deea23fe99c30..896765722bf32 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,17 +13,17 @@ repos: - id: flake8 name: flake8-pyx language: python_venv - files: \.pyx$ + files: \.(pyx|pxd)$ types: - file args: [--append-config=flake8/cython.cfg] - id: flake8 name: flake8-pxd language: python_venv - files: \.(pxd|pxi\.in)$ + files: \.pxi\.in$ types: - file - args: [--append-config=flake8/cython-header.cfg] + args: [--append-config=flake8/cython-template.cfg] - repo: https://github.com/pre-commit/mirrors-isort rev: v4.3.21 hooks: diff --git a/ci/code_checks.sh b/ci/code_checks.sh index c8f0a9ae9e48d..7eb80077c4fab 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -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 + 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 --append-config=flake8/cython-header.cfg + 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" diff --git a/flake8/cython-header.cfg b/flake8/cython-template.cfg similarity index 72% rename from flake8/cython-header.cfg rename to flake8/cython-template.cfg index 7f6de31eb315c..61562bd7701b1 100644 --- a/flake8/cython-header.cfg +++ b/flake8/cython-template.cfg @@ -1,4 +1,4 @@ [flake8] -filename = *.pxd,*.pxi.in +filename = *.pxi.in select = E501,E302,E203,E111,E114,E221,E303,E231,E126,F403 diff --git a/flake8/cython.cfg b/flake8/cython.cfg index f883aad726623..2dfe47b60b4c1 100644 --- a/flake8/cython.cfg +++ b/flake8/cython.cfg @@ -1,3 +1,3 @@ [flake8] -filename = *.pyx +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 diff --git a/pandas/_libs/sparse_op_helper.pxi.in b/pandas/_libs/sparse_op_helper.pxi.in index 996da4ca2f92b..ce665ca812131 100644 --- a/pandas/_libs/sparse_op_helper.pxi.in +++ b/pandas/_libs/sparse_op_helper.pxi.in @@ -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 diff --git a/pandas/_libs/tslibs/util.pxd b/pandas/_libs/tslibs/util.pxd index 936532a81c6d6..e7f6b3334eb65 100644 --- a/pandas/_libs/tslibs/util.pxd +++ b/pandas/_libs/tslibs/util.pxd @@ -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 From 9557accfd10e86cce7662a2ce41d529927fcde88 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Mon, 10 Feb 2020 22:22:17 +0100 Subject: [PATCH 6/6] Fix merge conflicts --- web/pandas_web.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/pandas_web.py b/web/pandas_web.py index a34a31feabce0..38ab78f5690e7 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -34,12 +34,13 @@ import time import typing -import feedparser import jinja2 -import markdown import requests import yaml +import feedparser +import markdown + class Preprocessors: """