Skip to content

Commit e1d0b67

Browse files
authored
CI: add pre-commit action, include pyupgrade (pandas-dev#36471)
1 parent ace1dd5 commit e1d0b67

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

.github/workflows/pre-commit.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ repos:
33
rev: 20.8b1
44
hooks:
55
- id: black
6-
language_version: python3
76
- repo: https://gitlab.com/pycqa/flake8
87
rev: 3.8.3
98
hooks:
109
- id: flake8
11-
language: python_venv
1210
additional_dependencies: [flake8-comprehensions>=3.1.0]
1311
- id: flake8
1412
name: flake8-pyx
15-
language: python_venv
1613
files: \.(pyx|pxd)$
1714
types:
1815
- file
1916
args: [--append-config=flake8/cython.cfg]
2017
- id: flake8
2118
name: flake8-pxd
22-
language: python_venv
2319
files: \.pxi\.in$
2420
types:
2521
- file
2622
args: [--append-config=flake8/cython-template.cfg]
27-
- repo: https://github.com/pre-commit/mirrors-isort
28-
rev: v5.2.2
23+
- repo: https://github.com/PyCQA/isort
24+
rev: 5.2.2
2925
hooks:
3026
- id: isort
31-
language: python_venv
3227
exclude: ^pandas/__init__\.py$|^pandas/core/api\.py$
28+
- repo: https://github.com/asottile/pyupgrade
29+
rev: v2.7.2
30+
hooks:
31+
- id: pyupgrade
32+
args: [--py37-plus]

doc/source/development/contributing.rst

+11
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ do not make sudden changes to the code that could have the potential to break
634634
a lot of user code as a result, that is, we need it to be as *backwards compatible*
635635
as possible to avoid mass breakages.
636636

637+
In addition to ``./ci/code_checks.sh``, some extra checks are run by
638+
``pre-commit`` - see :ref:`here <contributing.pre-commit>` for how to
639+
run them.
640+
637641
Additional standards are outlined on the :ref:`pandas code style guide <code_style>`
638642

639643
Optional dependencies
@@ -826,6 +830,13 @@ remain up-to-date with our code checks as they change.
826830

827831
Note that if needed, you can skip these checks with ``git commit --no-verify``.
828832

833+
If you don't want to use ``pre-commit`` as part of your workflow, you can still use it
834+
to run its checks by running::
835+
836+
pre-commit run --files <files you have modified>
837+
838+
without having to have done ``pre-commit install`` beforehand.
839+
829840
Backwards compatibility
830841
~~~~~~~~~~~~~~~~~~~~~~~
831842

doc/sphinxext/announce.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- encoding:utf-8 -*-
32
"""
43
Script to generate contributor and pull request lists
54

environment.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ dependencies:
2222
- flake8-rst>=0.6.0,<=0.7.0 # linting of code blocks in rst files
2323
- isort>=5.2.1 # check that imports are in the right order
2424
- mypy=0.782
25+
- pre-commit
2526
- pycodestyle # used by flake8
27+
- pyupgrade
2628

2729
# documentation
2830
- gitpython # obtain contributors from git for whatsnew

requirements-dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ flake8-comprehensions>=3.1.0
1313
flake8-rst>=0.6.0,<=0.7.0
1414
isort>=5.2.1
1515
mypy==0.782
16+
pre-commit
1617
pycodestyle
18+
pyupgrade
1719
gitpython
1820
gitdb
1921
sphinx

0 commit comments

Comments
 (0)