Skip to content

Commit 923ac2b

Browse files
WillAydjreback
authored andcommitted
MyPy CI Configuration (pandas-dev#25844)
1 parent b878f5b commit 923ac2b

File tree

7 files changed

+229
-6
lines changed

7 files changed

+229
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ dist
6161
.coverage
6262
coverage.xml
6363
coverage_html_report
64+
.mypy_cache
6465
*.pytest_cache
6566
# hypothesis test database
6667
.hypothesis/

azure-pipelines.yml

+7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ jobs:
8888
displayName: 'Docstring validation'
8989
condition: true
9090
91+
- script: |
92+
export PATH=$HOME/miniconda3/bin:$PATH
93+
source activate pandas-dev
94+
ci/code_checks.sh typing
95+
displayName: 'Typing validation'
96+
condition: true
97+
9198
- script: |
9299
export PATH=$HOME/miniconda3/bin:$PATH
93100
source activate pandas-dev

ci/code_checks.sh

+15-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
# $ ./ci/code_checks.sh doctests # run doctests
1717
# $ ./ci/code_checks.sh docstrings # validate docstring errors
1818
# $ ./ci/code_checks.sh dependencies # check that dependencies are consistent
19+
# $ ./ci/code_checks.sh typing # run static type analysis
1920

20-
[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "dependencies" ]] || \
21-
{ echo "Unknown command $1. Usage: $0 [lint|patterns|code|doctests|docstrings|dependencies]"; exit 9999; }
21+
[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "dependencies" || "$1" == "typing" ]] || \
22+
{ echo "Unknown command $1. Usage: $0 [lint|patterns|code|doctests|docstrings|dependencies|typing]"; exit 9999; }
2223

2324
BASE_DIR="$(dirname $0)/.."
2425
RET=0
@@ -256,4 +257,16 @@ if [[ -z "$CHECK" || "$CHECK" == "dependencies" ]]; then
256257

257258
fi
258259

260+
### TYPING ###
261+
if [[ -z "$CHECK" || "$CHECK" == "typing" ]]; then
262+
263+
echo "mypy --version"
264+
mypy --version
265+
266+
MSG='Performing static analysis using mypy' ; echo $MSG
267+
mypy pandas
268+
RET=$(($RET + $?)) ; echo $MSG "DONE"
269+
fi
270+
271+
259272
exit $RET

environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- hypothesis>=3.82
2020
- isort
2121
- moto
22+
- mypy
2223
- pycodestyle
2324
- pytest>=4.0.2
2425
- pytest-mock

mypy.ini

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
[mypy]
2+
ignore_missing_imports=True
3+
follow_imports=silent
4+
5+
[mypy-pandas.conftest,pandas.tests.*]
6+
ignore_errors=True
7+
8+
[mypy-pandas._config.config]
9+
ignore_errors=True
10+
11+
[mypy-pandas._version]
12+
ignore_errors=True
13+
14+
[mypy-pandas.compat]
15+
ignore_errors=True
16+
17+
[mypy-pandas.compat.numpy.function]
18+
ignore_errors=True
19+
20+
[mypy-pandas.compat.pickle_compat]
21+
ignore_errors=True
22+
23+
[mypy-pandas.core.accessor]
24+
ignore_errors=True
25+
26+
[mypy-pandas.core.api]
27+
ignore_errors=True
28+
29+
[mypy-pandas.core.apply]
30+
ignore_errors=True
31+
32+
[mypy-pandas.core.arrays.array_]
33+
ignore_errors=True
34+
35+
[mypy-pandas.core.arrays.datetimelike]
36+
ignore_errors=True
37+
38+
[mypy-pandas.core.arrays.integer]
39+
ignore_errors=True
40+
41+
[mypy-pandas.core.arrays.interval]
42+
ignore_errors=True
43+
44+
[mypy-pandas.core.arrays.numpy_]
45+
ignore_errors=True
46+
47+
[mypy-pandas.core.arrays.period]
48+
ignore_errors=True
49+
50+
[mypy-pandas.core.arrays.sparse]
51+
ignore_errors=True
52+
53+
[mypy-pandas.core.arrays.timedeltas]
54+
ignore_errors=True
55+
56+
[mypy-pandas.core.base]
57+
ignore_errors=True
58+
59+
[mypy-pandas.core.computation.expr]
60+
ignore_errors=True
61+
62+
[mypy-pandas.core.computation.ops]
63+
ignore_errors=True
64+
65+
[mypy-pandas.core.computation.pytables]
66+
ignore_errors=True
67+
68+
[mypy-pandas.core.config]
69+
ignore_errors=True
70+
71+
[mypy-pandas.core.config_init]
72+
ignore_errors=True
73+
74+
[mypy-pandas.core.dtypes.dtypes]
75+
ignore_errors=True
76+
77+
[mypy-pandas.core.dtypes.missing]
78+
ignore_errors=True
79+
80+
[mypy-pandas.core.frame]
81+
ignore_errors=True
82+
83+
[mypy-pandas.core.generic]
84+
ignore_errors=True
85+
86+
[mypy-pandas.core.groupby.generic]
87+
ignore_errors=True
88+
89+
[mypy-pandas.core.groupby.groupby]
90+
ignore_errors=True
91+
92+
[mypy-pandas.core.groupby.ops]
93+
ignore_errors=True
94+
95+
[mypy-pandas.core.indexes.base]
96+
ignore_errors=True
97+
98+
[mypy-pandas.core.indexes.datetimelike]
99+
ignore_errors=True
100+
101+
[mypy-pandas.core.indexes.datetimes]
102+
ignore_errors=True
103+
104+
[mypy-pandas.core.indexes.period]
105+
ignore_errors=True
106+
107+
[mypy-pandas.core.indexes.timedeltas]
108+
ignore_errors=True
109+
110+
[mypy-pandas.core.indexing]
111+
ignore_errors=True
112+
113+
[mypy-pandas.core.internals.blocks]
114+
ignore_errors=True
115+
116+
[mypy-pandas.core.ops]
117+
ignore_errors=True
118+
119+
[mypy-pandas.core.panel]
120+
ignore_errors=True
121+
122+
[mypy-pandas.core.resample]
123+
ignore_errors=True
124+
125+
[mypy-pandas.core.reshape.concat]
126+
ignore_errors=True
127+
128+
[mypy-pandas.core.reshape.merge]
129+
ignore_errors=True
130+
131+
[mypy-pandas.core.reshape.reshape]
132+
ignore_errors=True
133+
134+
[mypy-pandas.core.reshape.tile]
135+
ignore_errors=True
136+
137+
[mypy-pandas.core.series]
138+
ignore_errors=True
139+
140+
[mypy-pandas.core.sparse.frame]
141+
ignore_errors=True
142+
143+
[mypy-pandas.core.strings]
144+
ignore_errors=True
145+
146+
[mypy-pandas.core.util.hashing]
147+
ignore_errors=True
148+
149+
[mypy-pandas.core.window]
150+
ignore_errors=True
151+
152+
[mypy-pandas.io.clipboards]
153+
ignore_errors=True
154+
155+
[mypy-pandas.io.feather_format]
156+
ignore_errors=True
157+
158+
[mypy-pandas.io.formats.css]
159+
ignore_errors=True
160+
161+
[mypy-pandas.io.html]
162+
ignore_errors=True
163+
164+
[mypy-pandas.io.json.json]
165+
ignore_errors=True
166+
167+
[mypy-pandas.io.json.normalize]
168+
ignore_errors=True
169+
170+
[mypy-pandas.io.json.table_schema]
171+
ignore_errors=True
172+
173+
[mypy-pandas.io.packers]
174+
ignore_errors=True
175+
176+
[mypy-pandas.io.parquet]
177+
ignore_errors=True
178+
179+
[mypy-pandas.io.pytables]
180+
ignore_errors=True
181+
182+
[mypy-pandas.io.stata]
183+
ignore_errors=True
184+
185+
[mypy-pandas.plotting._core]
186+
ignore_errors=True
187+
188+
[mypy-pandas.tseries.frequencies]
189+
ignore_errors=True
190+
191+
[mypy-pandas.tseries.holiday]
192+
ignore_errors=True
193+
194+
[mypy-pandas.tseries.offsets]
195+
ignore_errors=True
196+
197+
[mypy-pandas.util._doctools]
198+
ignore_errors=True
199+
200+
[mypy-pandas.util.testing]
201+
ignore_errors=True

pandas/core/internals/blocks.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1827,10 +1827,9 @@ def interpolate(self, method='pad', axis=0, inplace=False, limit=None,
18271827
placement=self.mgr_locs)
18281828

18291829
def shift(self,
1830-
periods, # type: int
1831-
axis=0, # type: libinternals.BlockPlacement
1832-
fill_value=None): # type: Any
1833-
# type: (...) -> List[ExtensionBlock]
1830+
periods: int,
1831+
axis: libinternals.BlockPlacement = 0,
1832+
fill_value: Any = None) -> List['ExtensionBlock']:
18341833
"""
18351834
Shift the block by `periods`.
18361835

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gitpython
1010
hypothesis>=3.82
1111
isort
1212
moto
13+
mypy
1314
pycodestyle
1415
pytest>=4.0.2
1516
pytest-mock

0 commit comments

Comments
 (0)