Skip to content

Commit

Permalink
BUG: mypy: bump mypy version and fix new typing errors
Browse files Browse the repository at this point in the history
`mypy` 0.770 was broken on Python 3.9.0a5. Hence, the requirement
file is altered to always download the latest `mypy` version.
See https://mail.python.org/pipermail/scipy-dev/2021-February/024580.html

Also, latest mypy version reported some more typing errors which have been
resolved in this commit.
  • Loading branch information
tirthasheshpatel committed Feb 26, 2021
1 parent 657a20d commit 7c6431a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ ignore_errors = True
[mypy-scipy.spatial.tests.test_distance]
ignore_errors = True

[mypy-scipy.stats.tests.test_qmc]
ignore_errors = True

#
# Files referencing compiled code that needs stubs added.
#
Expand Down
2 changes: 1 addition & 1 deletion mypy_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mypy==0.770
mypy
typing_extensions
git+git://github.com/numpy/numpy-stubs.git@master
2 changes: 1 addition & 1 deletion scipy/fft/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import scipy.fft
from scipy.fft import set_backend
from scipy.fft import _pocketfft
from scipy.fft.tests import mock_backend
from scipy.fft.tests import mock_backend # type: ignore[import]

from numpy.testing import assert_allclose, assert_equal
import pytest
Expand Down
2 changes: 1 addition & 1 deletion scipy/odr/_add_newdocs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from numpy import add_newdoc
from numpy import add_newdoc # type: ignore[attr-defined]

add_newdoc('scipy.odr', 'odr',
"""
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/orthogonal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class orthopoly1d(numpy.poly1d):
def limits(self) -> Tuple[float, float]: ...
def wfunc(x: float) -> float: ...
# TODO: ArrayLike
def __call__(self, x: Any) -> numpy.ndarray: ...
def __call__(self, x: Any) -> Any: ...

def legendre(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
def chebyt(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
Expand Down
13 changes: 7 additions & 6 deletions scipy/stats/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2831,12 +2831,13 @@ def test_percentileofscore():
assert_raises(ValueError, pcos, [1, 2, 3, 3, 4], 3, kind='unrecognized')


PowerDivCase = namedtuple('Case', ['f_obs', 'f_exp', 'ddof', 'axis',
'chi2', # Pearson's
'log', # G-test (log-likelihood)
'mod_log', # Modified log-likelihood
'cr', # Cressie-Read (lambda=2/3)
])
PowerDivCase = namedtuple('Case', # type: ignore[name-match]
['f_obs', 'f_exp', 'ddof', 'axis',
'chi2', # Pearson's
'log', # G-test (log-likelihood)
'mod_log', # Modified log-likelihood
'cr', # Cressie-Read (lambda=2/3)
])

# The details of the first two elements in power_div_1d_cases are used
# in a test in TestPowerDivergence. Check that code before making
Expand Down

0 comments on commit 7c6431a

Please sign in to comment.