Skip to content
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

MyPy CI Configuration #25844

Merged
merged 17 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dist
.coverage
coverage.xml
coverage_html_report
.mypy_cache
*.pytest_cache
# hypothesis test database
.hypothesis/
Expand Down
7 changes: 7 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ jobs:
displayName: 'Docstring validation'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/code_checks.sh typing
displayName: 'Typing validation'
condition: true

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
Expand Down
17 changes: 15 additions & 2 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
# $ ./ci/code_checks.sh doctests # run doctests
# $ ./ci/code_checks.sh docstrings # validate docstring errors
# $ ./ci/code_checks.sh dependencies # check that dependencies are consistent
# $ ./ci/code_checks.sh typing # run static type analysis

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

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

fi

### TYPING ###
if [[ -z "$CHECK" || "$CHECK" == "typing" ]]; then

echo "mypy --version"
mypy --version

MSG='Performing static analysis on items in mypy_whitelist.txt' ; echo $MSG
mypy @mypy_whitelist.txt
RET=$(($RET + $?)) ; echo $MSG "DONE"
fi


exit $RET
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
- hypothesis>=3.82
- isort
- moto
- mypy
- pycodestyle
- pytest>=4.0.2
- pytest-mock
Expand Down
6 changes: 6 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
jreback marked this conversation as resolved.
Show resolved Hide resolved
ignore_missing_imports=True
follow_imports=silent

[mypy-pandas.conftest,pandas.tests.*]
ignore_errors=True
4 changes: 4 additions & 0 deletions mypy_whitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pandas/core/arrays/base.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some comments here to indicate what this file is. Also can you add a small new doc section on typing (just a starter is good, can expand over time). on how to type / how to update this file etc.

pandas/core/arrays/datetimes.py
pandas/core/common.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really wish this were a blacklist file :>

pandas/core/dtypes/base.py
7 changes: 3 additions & 4 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,10 +1827,9 @@ def interpolate(self, method='pad', axis=0, inplace=False, limit=None,
placement=self.mgr_locs)

def shift(self,
periods, # type: int
axis=0, # type: libinternals.BlockPlacement
fill_value=None): # type: Any
# type: (...) -> List[ExtensionBlock]
periods: int,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was kind of annoying to fix some syntax issues and make this work with LINT so I just converted to new syntax to avoid hassle

axis: libinternals.BlockPlacement = 0,
fill_value: Any = None) -> List['ExtensionBlock']:
"""
Shift the block by `periods`.

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gitpython
hypothesis>=3.82
isort
moto
mypy
pycodestyle
pytest>=4.0.2
pytest-mock
Expand Down