Skip to content

Commit d20b0cb

Browse files
Merge remote-tracking branch 'upstream/main' into internals-column-setitem
2 parents 103d1fe + d2a7eff commit d20b0cb

File tree

20 files changed

+232
-175
lines changed

20 files changed

+232
-175
lines changed

.github/workflows/code-checks.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ jobs:
6767
environment-file: ${{ env.ENV_FILE }}
6868
use-only-tar-bz2: true
6969

70-
- name: Install node.js (for pyright)
71-
uses: actions/setup-node@v3
72-
with:
73-
node-version: "16"
74-
75-
- name: Install pyright
76-
# note: keep version in sync with .pre-commit-config.yaml
77-
run: npm install -g [email protected]
78-
7970
- name: Build Pandas
8071
id: build
8172
uses: ./.github/actions/build_pandas
@@ -96,8 +87,16 @@ jobs:
9687
run: ci/code_checks.sh docstrings
9788
if: ${{ steps.build.outcome == 'success' }}
9889

99-
- name: Run typing validation
100-
run: ci/code_checks.sh typing
90+
- name: Use existing environment for type checking
91+
run: |
92+
echo $PATH >> $GITHUB_PATH
93+
echo "PYTHONHOME=$PYTHONHOME" >> $GITHUB_ENV
94+
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
95+
96+
- name: Typing
97+
uses: pre-commit/[email protected]
98+
with:
99+
extra_args: --hook-stage manual --all-files
101100
if: ${{ steps.build.outcome == 'success' }}
102101

103102
- name: Run docstring validation script tests

.pre-commit-config.yaml

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
minimum_pre_commit_version: 2.9.2
1+
minimum_pre_commit_version: 2.15.0
22
exclude: ^LICENSES/|\.(html|csv|svg)$
3+
# reserve "manual" for mypy and pyright
4+
default_stages: [commit, merge-commit, push, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, post-rewrite]
35
ci:
46
autofix_prs: false
57
repos:
@@ -31,7 +33,9 @@ repos:
3133
- id: debug-statements
3234
- id: end-of-file-fixer
3335
exclude: \.txt$
36+
stages: [commit, merge-commit, push, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, post-rewrite]
3437
- id: trailing-whitespace
38+
stages: [commit, merge-commit, push, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, post-rewrite]
3539
- repo: https://github.com/cpplint/cpplint
3640
rev: 1.6.0
3741
hooks:
@@ -84,12 +88,22 @@ repos:
8488
- id: pyright
8589
name: pyright
8690
entry: pyright
91+
# note: assumes python env is setup and activated
8792
language: node
8893
pass_filenames: false
8994
types: [python]
9095
stages: [manual]
91-
# note: keep version in sync with .github/workflows/code-checks.yml
92-
additional_dependencies: ['[email protected]']
96+
additional_dependencies: ['[email protected]']
97+
- repo: local
98+
hooks:
99+
- id: mypy
100+
name: mypy
101+
entry: mypy
102+
# note: assumes python env is setup and activated
103+
language: system
104+
pass_filenames: false
105+
types: [python]
106+
stages: [manual]
93107
- repo: local
94108
hooks:
95109
- id: flake8-rst

asv_bench/benchmarks/arithmetic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def time_add_overflow_both_arg_nan(self):
420420

421421

422422
hcal = pd.tseries.holiday.USFederalHolidayCalendar()
423-
# These offsets currently raise a NotImplimentedError with .apply_index()
423+
# These offsets currently raise a NotImplementedError with .apply_index()
424424
non_apply = [
425425
pd.offsets.Day(),
426426
pd.offsets.BYearEnd(),

asv_bench/benchmarks/tslibs/normalize.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ def setup(self, size, tz):
3636
raise NotImplementedError
3737

3838
def time_normalize_i8_timestamps(self, size, tz):
39-
normalize_i8_timestamps(self.i8data, tz)
39+
# 10 i.e. NPY_FR_ns
40+
normalize_i8_timestamps(self.i8data, tz, 10)
4041

4142
def time_is_date_array_normalized(self, size, tz):
4243
# TODO: cases with different levels of short-circuiting
43-
is_date_array_normalized(self.i8data, tz)
44+
# 10 i.e. NPY_FR_ns
45+
is_date_array_normalized(self.i8data, tz, 10)

asv_bench/benchmarks/tslibs/offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
pass
1515

1616
hcal = pandas.tseries.holiday.USFederalHolidayCalendar()
17-
# These offsets currently raise a NotImplimentedError with .apply_index()
17+
# These offsets currently raise a NotImplementedError with .apply_index()
1818
non_apply = [
1919
offsets.Day(),
2020
offsets.BYearEnd(),

ci/code_checks.sh

+2-21
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
# $ ./ci/code_checks.sh code # checks on imported code
1212
# $ ./ci/code_checks.sh doctests # run doctests
1313
# $ ./ci/code_checks.sh docstrings # validate docstring errors
14-
# $ ./ci/code_checks.sh typing # run static type analysis
1514
# $ ./ci/code_checks.sh single-docs # check single-page docs build warning-free
1615

17-
[[ -z "$1" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" || "$1" == "single-docs" ]] || \
18-
{ echo "Unknown command $1. Usage: $0 [code|doctests|docstrings|typing]"; exit 9999; }
16+
[[ -z "$1" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "single-docs" ]] || \
17+
{ echo "Unknown command $1. Usage: $0 [code|doctests|docstrings]"; exit 9999; }
1918

2019
BASE_DIR="$(dirname $0)/.."
2120
RET=0
@@ -85,24 +84,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8584

8685
fi
8786

88-
### TYPING ###
89-
if [[ -z "$CHECK" || "$CHECK" == "typing" ]]; then
90-
91-
echo "mypy --version"
92-
mypy --version
93-
94-
MSG='Performing static analysis using mypy' ; echo $MSG
95-
mypy
96-
RET=$(($RET + $?)) ; echo $MSG "DONE"
97-
98-
# run pyright, if it is installed
99-
if command -v pyright &> /dev/null ; then
100-
MSG='Performing static analysis using pyright' ; echo $MSG
101-
pyright
102-
RET=$(($RET + $?)) ; echo $MSG "DONE"
103-
fi
104-
fi
105-
10687
### SINGLE-PAGE DOCS ###
10788
if [[ -z "$CHECK" || "$CHECK" == "single-docs" ]]; then
10889
python doc/make.py --warnings-are-errors --single pandas.Series.value_counts

doc/source/development/contributing_codebase.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ contributing them to the project::
2323

2424
./ci/code_checks.sh
2525

26-
The script validates the doctests, formatting in docstrings, static typing, and
26+
The script validates the doctests, formatting in docstrings, and
2727
imported modules. It is possible to run the checks independently by using the
28-
parameters ``docstring``, ``code``, ``typing``, and ``doctests``
28+
parameters ``docstring``, ``code``, and ``doctests``
2929
(e.g. ``./ci/code_checks.sh doctests``).
3030

3131
In addition, because a lot of people use our library, it is important that we
3232
do not make sudden changes to the code that could have the potential to break
3333
a lot of user code as a result, that is, we need it to be as *backwards compatible*
3434
as possible to avoid mass breakages.
3535

36-
In addition to ``./ci/code_checks.sh``, some extra checks are run by
37-
``pre-commit`` - see :ref:`here <contributing.pre-commit>` for how to
38-
run them.
36+
In addition to ``./ci/code_checks.sh``, some extra checks (including static type
37+
checking) are run by ``pre-commit`` - see :ref:`here <contributing.pre-commit>`
38+
for how to run them.
3939

4040
.. _contributing.pre-commit:
4141

@@ -260,9 +260,9 @@ pandas uses `mypy <http://mypy-lang.org>`_ and `pyright <https://github.com/micr
260260

261261
.. code-block:: shell
262262
263-
./ci/code_checks.sh typing
263+
pre-commit run --hook-stage manual --all-files
264264
265-
A recent version of ``numpy`` (>=1.21.0) is required for type validation.
265+
in your activated python environment. A recent version of ``numpy`` (>=1.22.0) is required for type validation.
266266

267267
.. _contributing.ci:
268268

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
- flake8-comprehensions=3.7.0 # used by flake8, linting of unnecessary comprehensions
2626
- isort>=5.2.1 # check that imports are in the right order
2727
- mypy=0.950
28-
- pre-commit>=2.9.2
28+
- pre-commit>=2.15.0
2929
- pycodestyle # used by flake8
3030
- pyupgrade
3131

0 commit comments

Comments
 (0)