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

Use type(x) == T for type narrowing #10284

Merged
merged 15 commits into from
Apr 12, 2021

Conversation

pranavrajpal
Copy link
Contributor

Fixes #4445

This makes mypy use expressions like type(x) == T during type narrowing similar to how it already does for isinstance(x, T).

This also adds support for using type(x) is T, as well as checking the types of multiple variables at the same time, like type(x) == type(y) == T.

This doesn't do any type narrowing when multiple literal types are present in the comparison, such as in type(x) == int == str or type(x) == int == int. Expressions of that kind should always be False if those literal types aren't all the same, and are relatively pointless if all of the literal types are the same, so I think it's fine not supporting those. I can try adding support for the case when those literal types are the same if necessary.

Test Plan

I added several tests to make sure that mypy was actually using checks of this kind to narrow types inside if statements.

This makes mypy use expressions like type(some_expression) == some_type
for type narrowing similar to how it already does for isinstance checks.

This also adds some tests to make sure that this is actually being used
in type narrowing.
@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2021

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit.git)
- lib/tests/streamlit/magic_test.py: note: In member "_testCode" of class "MagicTest":
- lib/tests/streamlit/magic_test.py:36:67: error: "AST" has no attribute "func"  [attr-defined]


Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Please have a look my comment about dealing with 'else' blocks and union types. I'll do a full review once that use case works and is tested.


y: Any
if type(y) is int:
reveal_type(y) # N: Revealed type is "builtins.int"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add also test case where you narrow from Union[int, str] to int, and there is an else block. For example, something like this:

def f(x: Union[int, str]) -> None:
    if type(x) is int:
        reveal_type(x)  # int
    else:
        reveal_type(x)  # Union[int, str]

The else block should use the original type, since instances of int subclasses (e.g. bool) will be handled in the else block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I have added a test case for this and modified the type checker to handle this. Could you take a look at my changes when you get the chance?

`type(x) == T` is False when x is an instance of a subclass of T, which
isn't the same as `isinstance(x, T)`, which checks if x is an instance
of T or a subclass of T. That means that x could be a subclass of T in
the else case, so we can't narrow x's type to exclude this possibility.
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2021

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit.git)
- lib/tests/streamlit/magic_test.py: note: In member "_testCode" of class "MagicTest":
- lib/tests/streamlit/magic_test.py:36:67: error: "AST" has no attribute "func"  [attr-defined]


Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! This adds a useful new feature that removes some false positives, which is always nice. Looks good, just a few comments.

mypy/checker.py Outdated
else:
type_being_compared = current_type

if_maps = [] # type: List[TypeMap]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move the remaining operations behind if exprs_in_type_calls:, as an optimization? This way the remaining code will only be run if there is something to do. It also makes it easier to see that the code does nothing unless there is a type(x) somewhere.

if type(x) is int:
reveal_type(x) # N: Revealed type is "builtins.int"
else:
reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Test type(x) is not int with Union[int, str] (also !=). It shouldn't do anything, since the type could be a subclass of int.

Optionally, if we are dealing with a @final class (TypeInfo with is_final true), we can actually restrict the type away in the else block. If the type of x is Union[C, D], and C is final, the type of x in the else block could be just D, since there can be no subclasses of C:

x: Union[C, D]
if type(x) is C:
    reveal_type(x)  # C
else:
    reveal_type(x)  # D, but only if C is final

It's fine to leave the handling of final classes as a follow-up issue, though. The current PR already improves things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you say that type(x) is not int shouldn't do anything, do you mean that it shouldn't do any narrowing, like this:

x: Union[int, str]
if type(x) is not int:
    reveal_type(x)  # Union[int, str]
else:
    reveal_type(x)  # Union[int, str]

Or do you mean that it should flip what it infers for the if and else cases:

x: Union[int, str]
if type(x) is not int:
    reveal_type(x)  # Union[int, str]
else:
    reveal_type(x)  # int

I think it would be the second one because I think the only way for type(x) is not int to be false is for x to be an int.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, the second is right, I was confused!

Refactor code for narrowing types based on checks that look like
type(x) == T into a new function
Avoid narrowing in a comparison with multiple types being compared to
each other even if there is a type(x) call being compared to one of them.
Return early if we haven't found any calls to type
Add tests to make sure that type(x) != T and type(x) is not T work as
expected (the same as type(x) == T and type(x) is T but with the if and
else branches switched.

Currently the type(x) != T check is failing because of a mypy error
about an unsupported left operand type.
@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2021

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit.git)
- lib/tests/streamlit/magic_test.py: note: In member "_testCode" of class "MagicTest":
- lib/tests/streamlit/magic_test.py:36:67: error: "AST" has no attribute "func"  [attr-defined]


Add fixtures to some of the tests to make mypy not show an error when we
try to compare types
@pranavrajpal
Copy link
Contributor Author

I've added the tests for type(x) is not int and type(x) != int and I made the type narrowing stop early if it didn't find any type(x) calls.

I'm still working on handling comparing the type of a variable to a final class.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2021

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit.git)
- lib/tests/streamlit/magic_test.py: note: In member "_testCode" of class "MagicTest":
- lib/tests/streamlit/magic_test.py:36:67: error: "AST" has no attribute "func"  [attr-defined]


Final types cannot be subclassed, so it's impossible for a subclass of a
final type to be used in the else case of a comparison of type(x) to a
final type. That means we can narrow types in the else case the same way
we would do for isinstance checks if type(x) is being compared to a
final type.
@pranavrajpal
Copy link
Contributor Author

I have added support for restricting the type of a variable in the else case if the type being compared is final.

Could you take a look and let me know what you think?

@pranavrajpal pranavrajpal requested a review from JukkaL April 9, 2021 21:08
lookup_typeinfo appears to crash with a KeyError if it can't find the
class corresponding to the given name, which becomes a problem when
we're trying to check if the type someone is comparing to is final.

This fixes that by assuming any types or classes we can't look up are
not final (so that we don't narrow types in the else case when it
doesn't make sense to).
lookup_typeinfo sometimes fails with an AssertionError, which we should
catch so that we don't crash mypy if that happens.
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit.git)
- lib/tests/streamlit/magic_test.py: note: In member "_testCode" of class "MagicTest":
- lib/tests/streamlit/magic_test.py:36:67: error: "AST" has no attribute "func"  [attr-defined]

scipy (https://github.com/scipy/scipy.git)
+ /tmp/mypy_primer/projects/_scipy_venv/lib/python3.8/site-packages/numpy/ma/core.py:3275: error: INTERNAL ERROR -- Please try using mypy master on Github:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
+ version: 0.820+dev.67457a32c2c2cbb0f161901972b240e0dea7da42
- scipy/special/_ellip_harm.py:3: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/special/orthogonal.pyi:10: error: Library stubs not installed for "typing_extensions" (or incompatible with Python 3.8)  [import]
- scipy/special/orthogonal.pyi:66: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:87: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:106: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:120: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:133: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:146: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:163: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:177: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:190: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:203: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:216: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:229: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:242: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:255: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/orthogonal.pyi:268: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
- scipy/special/tests/test_trig.py:4: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/special/tests/test_cosine_distr.py:5: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/special/_precompute/struve_convergence.py:47: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/special/spfun_stats.py:36: error: Module 'scipy.special' has no attribute 'gammaln'; maybe "gamma"?  [attr-defined]
- scipy/special/__init__.py:643: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/stats/_tukeylambda_stats.py:3: error: Module 'scipy.special' has no attribute 'beta'  [attr-defined]
- scipy/special/tests/test_wright_bessel.py:24: error: Module 'scipy.special' has no attribute 'rgamma'; maybe "gamma" or "digamma"?  [attr-defined]
- scipy/special/tests/test_wright_bessel.py:24: error: Module 'scipy.special' has no attribute 'wright_bessel'  [attr-defined]
- scipy/special/tests/test_spfun_stats.py:6: error: Module 'scipy.special' has no attribute 'gammaln'; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_sf_error.py:8: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/special/tests/test_sf_error.py:45: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:52: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:56: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:57: error: Module has no attribute "seterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:59: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:66: error: Module has no attribute "seterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:70: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:71: error: Module has no attribute "errstate"  [attr-defined]
- scipy/special/tests/test_sf_error.py:73: error: Module has no attribute "loggamma"; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_sf_error.py:74: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:78: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:79: error: Module has no attribute "errstate"  [attr-defined]
- scipy/special/tests/test_sf_error.py:81: error: Module has no attribute "spence"  [attr-defined]
- scipy/special/tests/test_sf_error.py:82: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:86: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:87: error: Module has no attribute "errstate"  [attr-defined]
- scipy/special/tests/test_sf_error.py:89: error: Module has no attribute "wrightomega"  [attr-defined]
- scipy/special/tests/test_sf_error.py:90: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:96: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:97: error: Module has no attribute "errstate"  [attr-defined]
- scipy/special/tests/test_sf_error.py:99: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:103: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_sf_error.py:104: error: Module has no attribute "errstate"  [attr-defined]
- scipy/special/tests/test_sf_error.py:105: error: Module has no attribute "gammaln"; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_sf_error.py:107: error: Module has no attribute "spence"  [attr-defined]
- scipy/special/tests/test_sf_error.py:108: error: Module has no attribute "geterr"  [attr-defined]
- scipy/special/tests/test_logit.py:4: error: Module 'scipy.special' has no attribute 'expit'  [attr-defined]
- scipy/special/tests/test_logit.py:4: error: Module 'scipy.special' has no attribute 'logit'  [attr-defined]
- scipy/special/tests/test_exponential_integrals.py:39: error: Module has no attribute "expi"  [attr-defined]
- scipy/special/tests/test_exponential_integrals.py:40: error: Module has no attribute "expi"  [attr-defined]
- scipy/special/tests/test_exponential_integrals.py:41: error: Module has no attribute "expi"  [attr-defined]
- scipy/special/tests/test_erfinv.py:34: error: Module has no attribute "erfinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:35: error: Module has no attribute "erfinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:36: error: Module has no attribute "erfinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:37: error: Module has no attribute "erfinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:38: error: Module has no attribute "erfinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:39: error: Module has no attribute "erfcinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:40: error: Module has no attribute "erfcinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:41: error: Module has no attribute "erfcinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:42: error: Module has no attribute "erfcinv"  [attr-defined]
- scipy/special/tests/test_erfinv.py:43: error: Module has no attribute "erfcinv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:44: error: Module has no attribute "agm"  [attr-defined]
- scipy/special/tests/test_cython_special.py:45: error: Module has no attribute "airy"  [attr-defined]
- scipy/special/tests/test_cython_special.py:46: error: Module has no attribute "airye"  [attr-defined]
- scipy/special/tests/test_cython_special.py:47: error: Module has no attribute "bdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:48: error: Module has no attribute "bdtrc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:49: error: Module has no attribute "bdtri"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:50: error: Module has no attribute "bdtrik"  [attr-defined]
- scipy/special/tests/test_cython_special.py:51: error: Module has no attribute "bdtrin"  [attr-defined]
- scipy/special/tests/test_cython_special.py:52: error: Module has no attribute "bei"  [attr-defined]
- scipy/special/tests/test_cython_special.py:53: error: Module has no attribute "beip"  [attr-defined]
- scipy/special/tests/test_cython_special.py:54: error: Module has no attribute "ber"  [attr-defined]
- scipy/special/tests/test_cython_special.py:55: error: Module has no attribute "berp"  [attr-defined]
- scipy/special/tests/test_cython_special.py:56: error: Module has no attribute "besselpoly"  [attr-defined]
- scipy/special/tests/test_cython_special.py:57: error: Module has no attribute "beta"  [attr-defined]
- scipy/special/tests/test_cython_special.py:58: error: Module has no attribute "betainc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:59: error: Module has no attribute "betaincinv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:60: error: Module has no attribute "betaln"  [attr-defined]
- scipy/special/tests/test_cython_special.py:61: error: Module has no attribute "binom"  [attr-defined]
- scipy/special/tests/test_cython_special.py:62: error: Module has no attribute "boxcox"  [attr-defined]
- scipy/special/tests/test_cython_special.py:63: error: Module has no attribute "boxcox1p"  [attr-defined]
- scipy/special/tests/test_cython_special.py:64: error: Module has no attribute "btdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:65: error: Module has no attribute "btdtri"  [attr-defined]
- scipy/special/tests/test_cython_special.py:66: error: Module has no attribute "btdtria"  [attr-defined]
- scipy/special/tests/test_cython_special.py:67: error: Module has no attribute "btdtrib"  [attr-defined]
- scipy/special/tests/test_cython_special.py:68: error: Module has no attribute "cbrt"  [attr-defined]
- scipy/special/tests/test_cython_special.py:69: error: Module has no attribute "chdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:70: error: Module has no attribute "chdtrc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:71: error: Module has no attribute "chdtri"  [attr-defined]
- scipy/special/tests/test_cython_special.py:72: error: Module has no attribute "chdtriv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:73: error: Module has no attribute "chndtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:74: error: Module has no attribute "chndtridf"  [attr-defined]
- scipy/special/tests/test_cython_special.py:75: error: Module has no attribute "chndtrinc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:76: error: Module has no attribute "chndtrix"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:77: error: Module has no attribute "cosdg"  [attr-defined]
- scipy/special/tests/test_cython_special.py:78: error: Module has no attribute "cosm1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:79: error: Module has no attribute "cotdg"  [attr-defined]
- scipy/special/tests/test_cython_special.py:80: error: Module has no attribute "dawsn"  [attr-defined]
- scipy/special/tests/test_cython_special.py:81: error: Module has no attribute "ellipe"  [attr-defined]
- scipy/special/tests/test_cython_special.py:82: error: Module has no attribute "ellipeinc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:83: error: Module has no attribute "ellipj"  [attr-defined]
- scipy/special/tests/test_cython_special.py:84: error: Module has no attribute "ellipkinc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:85: error: Module has no attribute "ellipkm1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:86: error: Module has no attribute "ellipk"  [attr-defined]
- scipy/special/tests/test_cython_special.py:87: error: Module has no attribute "entr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:88: error: Module has no attribute "erf"  [attr-defined]
- scipy/special/tests/test_cython_special.py:89: error: Module has no attribute "erfc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:90: error: Module has no attribute "erfcx"  [attr-defined]
- scipy/special/tests/test_cython_special.py:91: error: Module has no attribute "erfi"  [attr-defined]
- scipy/special/tests/test_cython_special.py:92: error: Module has no attribute "erfinv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:93: error: Module has no attribute "erfcinv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:94: error: Module has no attribute "eval_chebyc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:95: error: Module has no attribute "eval_chebys"  [attr-defined]
- scipy/special/tests/test_cython_special.py:97: error: Module has no attribute "eval_chebyt"  [attr-defined]
- scipy/special/tests/test_cython_special.py:99: error: Module has no attribute "eval_chebyu"  [attr-defined]
- scipy/special/tests/test_cython_special.py:101: error: Module has no attribute "eval_gegenbauer"; maybe "gegenbauer"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:103: error: Module has no attribute "eval_genlaguerre"; maybe "genlaguerre"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:105: error: Module has no attribute "eval_hermite"  [attr-defined]
- scipy/special/tests/test_cython_special.py:106: error: Module has no attribute "eval_hermitenorm"; maybe "hermitenorm"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:107: error: Module has no attribute "eval_jacobi"  [attr-defined]
- scipy/special/tests/test_cython_special.py:109: error: Module has no attribute "eval_laguerre"; maybe "laguerre"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:111: error: Module has no attribute "eval_legendre"; maybe "legendre"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:112: error: Module has no attribute "eval_sh_chebyt"; maybe "sh_chebyt"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:113: error: Module has no attribute "eval_sh_chebyu"; maybe "sh_chebyu"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:115: error: Module has no attribute "eval_sh_jacobi"; maybe "sh_jacobi"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:117: error: Module has no attribute "eval_sh_legendre"; maybe "sh_legendre"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:118: error: Module has no attribute "exp1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:119: error: Module has no attribute "exp10"  [attr-defined]
- scipy/special/tests/test_cython_special.py:120: error: Module has no attribute "exp2"  [attr-defined]
- scipy/special/tests/test_cython_special.py:121: error: Module has no attribute "expi"  [attr-defined]
- scipy/special/tests/test_cython_special.py:122: error: Module has no attribute "expit"  [attr-defined]
- scipy/special/tests/test_cython_special.py:123: error: Module has no attribute "expm1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:124: error: Module has no attribute "expn"  [attr-defined]
- scipy/special/tests/test_cython_special.py:125: error: Module has no attribute "exprel"  [attr-defined]
- scipy/special/tests/test_cython_special.py:126: error: Module has no attribute "fdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:127: error: Module has no attribute "fdtrc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:128: error: Module has no attribute "fdtri"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:129: error: Module has no attribute "fdtridfd"  [attr-defined]
- scipy/special/tests/test_cython_special.py:130: error: Module has no attribute "fresnel"  [attr-defined]
- scipy/special/tests/test_cython_special.py:132: error: Module has no attribute "gammainc"; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:133: error: Module has no attribute "gammaincc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:134: error: Module has no attribute "gammainccinv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:135: error: Module has no attribute "gammaincinv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:136: error: Module has no attribute "gammaln"; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:137: error: Module has no attribute "gammasgn"; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:138: error: Module has no attribute "gdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:139: error: Module has no attribute "gdtrc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:140: error: Module has no attribute "gdtria"  [attr-defined]
- scipy/special/tests/test_cython_special.py:141: error: Module has no attribute "gdtrib"  [attr-defined]
- scipy/special/tests/test_cython_special.py:142: error: Module has no attribute "gdtrix"  [attr-defined]
- scipy/special/tests/test_cython_special.py:144: error: Module has no attribute "hankel1e"; maybe "hankel1" or "hankel2"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:146: error: Module has no attribute "hankel2e"; maybe "hankel2" or "hankel1"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:147: error: Module has no attribute "huber"  [attr-defined]
- scipy/special/tests/test_cython_special.py:149: error: Module has no attribute "hyp1f1"; maybe "hyp0f1"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:150: error: Module has no attribute "hyp2f1"; maybe "hyp0f1"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:151: error: Module has no attribute "hyperu"  [attr-defined]
- scipy/special/tests/test_cython_special.py:152: error: Module has no attribute "i0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:153: error: Module has no attribute "i0e"  [attr-defined]
- scipy/special/tests/test_cython_special.py:154: error: Module has no attribute "i1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:155: error: Module has no attribute "i1e"  [attr-defined]
- scipy/special/tests/test_cython_special.py:156: error: Module has no attribute "inv_boxcox"  [attr-defined]
- scipy/special/tests/test_cython_special.py:157: error: Module has no attribute "inv_boxcox1p"  [attr-defined]
- scipy/special/tests/test_cython_special.py:158: error: Module has no attribute "it2i0k0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:159: error: Module has no attribute "it2j0y0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:160: error: Module has no attribute "it2struve0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:161: error: Module has no attribute "itairy"  [attr-defined]
- scipy/special/tests/test_cython_special.py:162: error: Module has no attribute "iti0k0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:163: error: Module has no attribute "itj0y0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:164: error: Module has no attribute "itmodstruve0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:165: error: Module has no attribute "itstruve0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:167: error: Module has no attribute "ive"; maybe "iv"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:168: error: Module has no attribute "j0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:169: error: Module has no attribute "j1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:171: error: Module has no attribute "jve"; maybe "jv"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:172: error: Module has no attribute "k0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:173: error: Module has no attribute "k0e"  [attr-defined]
- scipy/special/tests/test_cython_special.py:174: error: Module has no attribute "k1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:175: error: Module has no attribute "k1e"  [attr-defined]
- scipy/special/tests/test_cython_special.py:176: error: Module has no attribute "kei"  [attr-defined]
- scipy/special/tests/test_cython_special.py:177: error: Module has no attribute "keip"  [attr-defined]
- scipy/special/tests/test_cython_special.py:178: error: Module has no attribute "kelvin"  [attr-defined]
- scipy/special/tests/test_cython_special.py:179: error: Module has no attribute "ker"  [attr-defined]
- scipy/special/tests/test_cython_special.py:180: error: Module has no attribute "kerp"  [attr-defined]
- scipy/special/tests/test_cython_special.py:181: error: Module has no attribute "kl_div"  [attr-defined]
- scipy/special/tests/test_cython_special.py:182: error: Module has no attribute "kn"  [attr-defined]
- scipy/special/tests/test_cython_special.py:183: error: Module has no attribute "kolmogi"  [attr-defined]
- scipy/special/tests/test_cython_special.py:184: error: Module has no attribute "kolmogorov"  [attr-defined]
- scipy/special/tests/test_cython_special.py:186: error: Module has no attribute "kve"; maybe "kv"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:187: error: Module has no attribute "log1p"  [attr-defined]
- scipy/special/tests/test_cython_special.py:188: error: Module has no attribute "log_ndtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:189: error: Module has no attribute "loggamma"; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:190: error: Module has no attribute "logit"  [attr-defined]
- scipy/special/tests/test_cython_special.py:191: error: Module has no attribute "lpmv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:194: error: Module has no attribute "mathieu_cem"; maybe "mathieu_b" or "mathieu_a"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:195: error: Module has no attribute "mathieu_modcem1"; maybe "mathieu_odd_coef"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:196: error: Module has no attribute "mathieu_modcem2"; maybe "mathieu_odd_coef"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:197: error: Module has no attribute "mathieu_modsem1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:198: error: Module has no attribute "mathieu_modsem2"  [attr-defined]
- scipy/special/tests/test_cython_special.py:199: error: Module has no attribute "mathieu_sem"; maybe "mathieu_b" or "mathieu_a"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:200: error: Module has no attribute "modfresnelm"  [attr-defined]
- scipy/special/tests/test_cython_special.py:201: error: Module has no attribute "modfresnelp"  [attr-defined]
- scipy/special/tests/test_cython_special.py:202: error: Module has no attribute "modstruve"  [attr-defined]
- scipy/special/tests/test_cython_special.py:203: error: Module has no attribute "nbdtr"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:204: error: Module has no attribute "nbdtrc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:205: error: Module has no attribute "nbdtri"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:206: error: Module has no attribute "nbdtrik"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:207: error: Module has no attribute "nbdtrin"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:208: error: Module has no attribute "ncfdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:209: error: Module has no attribute "ncfdtri"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:210: error: Module has no attribute "ncfdtridfd"  [attr-defined]
- scipy/special/tests/test_cython_special.py:211: error: Module has no attribute "ncfdtridfn"  [attr-defined]
- scipy/special/tests/test_cython_special.py:212: error: Module has no attribute "ncfdtrinc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:213: error: Module has no attribute "nctdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:214: error: Module has no attribute "nctdtridf"  [attr-defined]
- scipy/special/tests/test_cython_special.py:215: error: Module has no attribute "nctdtrinc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:216: error: Module has no attribute "nctdtrit"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:217: error: Module has no attribute "ndtr"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:219: error: Module has no attribute "nrdtrimn"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:220: error: Module has no attribute "nrdtrisd"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:221: error: Module has no attribute "obl_ang1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:222: error: Module has no attribute "obl_ang1_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:223: error: Module has no attribute "obl_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:224: error: Module has no attribute "obl_rad1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:225: error: Module has no attribute "obl_rad1_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:226: error: Module has no attribute "obl_rad2"  [attr-defined]
- scipy/special/tests/test_cython_special.py:227: error: Module has no attribute "obl_rad2_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:228: error: Module has no attribute "pbdv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:229: error: Module has no attribute "pbvv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:230: error: Module has no attribute "pbwa"  [attr-defined]
- scipy/special/tests/test_cython_special.py:231: error: Module has no attribute "pdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:232: error: Module has no attribute "pdtrc"  [attr-defined]
- scipy/special/tests/test_cython_special.py:233: error: Module has no attribute "pdtri"; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:234: error: Module has no attribute "pdtrik"  [attr-defined]
- scipy/special/tests/test_cython_special.py:235: error: Module has no attribute "poch"  [attr-defined]
- scipy/special/tests/test_cython_special.py:236: error: Module has no attribute "pro_ang1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:237: error: Module has no attribute "pro_ang1_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:238: error: Module has no attribute "pro_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:239: error: Module has no attribute "pro_rad1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:240: error: Module has no attribute "pro_rad1_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:241: error: Module has no attribute "pro_rad2"  [attr-defined]
- scipy/special/tests/test_cython_special.py:242: error: Module has no attribute "pro_rad2_cv"  [attr-defined]
- scipy/special/tests/test_cython_special.py:243: error: Module has no attribute "pseudo_huber"  [attr-defined]
- scipy/special/tests/test_cython_special.py:245: error: Module has no attribute "radian"  [attr-defined]
- scipy/special/tests/test_cython_special.py:246: error: Module has no attribute "rel_entr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:247: error: Module has no attribute "rgamma"; maybe "gamma" or "digamma"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:248: error: Module has no attribute "round"  [attr-defined]
- scipy/special/tests/test_cython_special.py:253: error: Module has no attribute "shichi"  [attr-defined]
- scipy/special/tests/test_cython_special.py:254: error: Module has no attribute "sici"  [attr-defined]
- scipy/special/tests/test_cython_special.py:255: error: Module has no attribute "sindg"  [attr-defined]
- scipy/special/tests/test_cython_special.py:256: error: Module has no attribute "smirnov"  [attr-defined]
- scipy/special/tests/test_cython_special.py:257: error: Module has no attribute "smirnovi"  [attr-defined]
- scipy/special/tests/test_cython_special.py:258: error: Module has no attribute "spence"  [attr-defined]
- scipy/special/tests/test_cython_special.py:259: error: Module has no attribute "sph_harm"  [attr-defined]
- scipy/special/tests/test_cython_special.py:260: error: Module has no attribute "stdtr"  [attr-defined]
- scipy/special/tests/test_cython_special.py:261: error: Module has no attribute "stdtridf"  [attr-defined]
- scipy/special/tests/test_cython_special.py:262: error: Module has no attribute "stdtrit"  [attr-defined]
- scipy/special/tests/test_cython_special.py:263: error: Module has no attribute "struve"  [attr-defined]
- scipy/special/tests/test_cython_special.py:264: error: Module has no attribute "tandg"  [attr-defined]
- scipy/special/tests/test_cython_special.py:265: error: Module has no attribute "tklmbda"; maybe "lmbda"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:266: error: Module has no attribute "voigt_profile"  [attr-defined]
- scipy/special/tests/test_cython_special.py:267: error: Module has no attribute "wofz"  [attr-defined]
- scipy/special/tests/test_cython_special.py:268: error: Module has no attribute "wright_bessel"  [attr-defined]
- scipy/special/tests/test_cython_special.py:269: error: Module has no attribute "wrightomega"  [attr-defined]
- scipy/special/tests/test_cython_special.py:270: error: Module has no attribute "xlog1py"  [attr-defined]
- scipy/special/tests/test_cython_special.py:271: error: Module has no attribute "xlogy"  [attr-defined]
- scipy/special/tests/test_cython_special.py:272: error: Module has no attribute "y0"  [attr-defined]
- scipy/special/tests/test_cython_special.py:273: error: Module has no attribute "y1"  [attr-defined]
- scipy/special/tests/test_cython_special.py:274: error: Module has no attribute "yn"  [attr-defined]
- scipy/special/tests/test_cython_special.py:276: error: Module has no attribute "yve"; maybe "yv"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:277: error: Module has no attribute "zetac"; maybe "zeta"?  [attr-defined]
- scipy/special/tests/test_cython_special.py:278: error: Module has no attribute "owens_t"  [attr-defined]
- scipy/special/tests/test_boxcox.py:3: error: Module 'scipy.special' has no attribute 'boxcox'  [attr-defined]
- scipy/special/tests/test_boxcox.py:3: error: Module 'scipy.special' has no attribute 'boxcox1p'  [attr-defined]
- scipy/special/tests/test_boxcox.py:3: error: Module 'scipy.special' has no attribute 'inv_boxcox'  [attr-defined]
- scipy/special/tests/test_boxcox.py:3: error: Module 'scipy.special' has no attribute 'inv_boxcox1p'  [attr-defined]
- scipy/integrate/_quadrature.py:13: error: Module 'scipy.special' has no attribute 'gammaln'; maybe "gamma"?  [attr-defined]
+ scipy/special/__init__.py:643: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
+ scipy/special/_precompute/struve_convergence.py:47: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
+ scipy/special/tests/test_basic.py:36: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
+ scipy/special/tests/test_cosine_distr.py:5: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/special/tests/test_spence.py:4: error: Module 'scipy.special' has no attribute 'spence'  [attr-defined]
- scipy/special/tests/test_loggamma.py:5: error: Module 'scipy.special' has no attribute 'gammaln'; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_loggamma.py:5: error: Module 'scipy.special' has no attribute 'loggamma'; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_kolmogorov.py:9: error: Module 'scipy.special' has no attribute 'kolmogi'  [attr-defined]
- scipy/special/tests/test_kolmogorov.py:9: error: Module 'scipy.special' has no attribute 'kolmogorov'  [attr-defined]
- scipy/special/tests/test_kolmogorov.py:9: error: Module 'scipy.special' has no attribute 'smirnov'  [attr-defined]
- scipy/special/tests/test_kolmogorov.py:9: error: Module 'scipy.special' has no attribute 'smirnovi'  [attr-defined]
- scipy/special/tests/test_basic.py:36: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/special/tests/test_basic.py:37: error: Module 'scipy.special' has no attribute 'ellipk'  [attr-defined]
+ scipy/special/tests/test_sf_error.py:8: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
+ scipy/special/tests/test_trig.py:4: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
+ scipy/special/orthogonal.pyi:10: error: Library stubs not installed for "typing_extensions" (or incompatible with Python 3.8)  [import]
+ scipy/special/_ellip_harm.py:3: error: Cannot find implementation or library stub for module named "scipy.special._ufuncs"  [import]
- scipy/stats/_distn_infrastructure.py:20: error: Module 'scipy.special' has no attribute 'chndtr'  [attr-defined]
- scipy/stats/_distn_infrastructure.py:20: error: Module 'scipy.special' has no attribute 'entr'  [attr-defined]
- scipy/stats/_distn_infrastructure.py:20: error: Module 'scipy.special' has no attribute 'ive'; maybe "iv"?  [attr-defined]
- scipy/stats/_distn_infrastructure.py:20: error: Module 'scipy.special' has no attribute 'xlogy'  [attr-defined]
- scipy/stats/_hypotests.py:10: error: Module 'scipy.special' has no attribute 'gammaln'; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:89: error: Module has no attribute "poch"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:91: error: Module has no attribute "poch"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:93: error: Module has no attribute "poch"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:94: error: Module has no attribute "poch"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:302: error: Module has no attribute "eval_jacobi"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:353: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:354: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:355: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:358: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:368: error: Module has no attribute "eval_sh_jacobi"; maybe "sh_jacobi"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:405: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:406: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:407: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:410: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:420: error: Module has no attribute "eval_hermite"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:429: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:430: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:431: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:434: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:438: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:439: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:440: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:441: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:441: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:477: error: Module has no attribute "eval_hermitenorm"; maybe "hermitenorm"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:485: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:486: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:487: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:490: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:497: error: Module has no attribute "eval_gegenbauer"; maybe "gegenbauer"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:524: error: Module has no attribute "eval_chebyt"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:525: error: Module has no attribute "eval_chebyt"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:526: error: Module has no attribute "eval_chebyt"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:529: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:530: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:531: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:534: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:542: error: Module has no attribute "eval_chebyt"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:543: error: Module has no attribute "eval_chebyt"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:544: error: Module has no attribute "eval_chebyt"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:547: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:548: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:549: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:552: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:565: error: Module has no attribute "eval_chebyu"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:566: error: Module has no attribute "eval_chebyu"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:567: error: Module has no attribute "eval_chebyu"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:570: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:571: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:572: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:575: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:582: error: Module has no attribute "eval_chebyc"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:583: error: Module has no attribute "eval_chebyc"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:584: error: Module has no attribute "eval_chebyc"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:587: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:588: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:589: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:592: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:599: error: Module has no attribute "eval_chebys"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:600: error: Module has no attribute "eval_chebys"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:601: error: Module has no attribute "eval_chebys"  [attr-defined]
- scipy/special/tests/test_orthogonal.py:604: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:605: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:606: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:609: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:616: error: Module has no attribute "eval_sh_chebyt"; maybe "sh_chebyt"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:617: error: Module has no attribute "eval_sh_chebyt"; maybe "sh_chebyt"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:618: error: Module has no attribute "eval_sh_chebyt"; maybe "sh_chebyt"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:622: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:623: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:624: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:627: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:634: error: Module has no attribute "eval_sh_chebyu"; maybe "sh_chebyu"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:635: error: Module has no attribute "eval_sh_chebyu"; maybe "sh_chebyu"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:636: error: Module has no attribute "eval_sh_chebyu"; maybe "sh_chebyu"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:640: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:641: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:642: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:645: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:652: error: Module has no attribute "eval_legendre"; maybe "legendre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:653: error: Module has no attribute "eval_legendre"; maybe "legendre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:655: error: Module has no attribute "eval_legendre"; maybe "legendre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:659: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:660: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:661: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:664: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:671: error: Module has no attribute "eval_sh_legendre"; maybe "sh_legendre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:672: error: Module has no attribute "eval_sh_legendre"; maybe "sh_legendre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:674: error: Module has no attribute "eval_sh_legendre"; maybe "sh_legendre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:678: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:679: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:680: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:683: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:690: error: Module has no attribute "eval_laguerre"; maybe "laguerre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:691: error: Module has no attribute "eval_laguerre"; maybe "laguerre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:693: error: Module has no attribute "eval_laguerre"; maybe "laguerre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:697: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:698: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:699: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:702: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_orthogonal.py:709: error: Module has no attribute "eval_genlaguerre"; maybe "genlaguerre"?  [attr-defined]
- scipy/special/tests/test_orthogonal.py:734: error: Need more than 2 values to unpack (3 expected)  [misc]
- scipy/special/tests/test_orthogonal.py:735: error: Cannot determine type of "y"  [has-type]
- scipy/special/tests/test_orthogonal.py:736: error: Cannot determine type of "v"  [has-type]
- scipy/special/tests/test_orthogonal.py:739: error: Cannot determine type of "m"  [has-type]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'bdtrik'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'beta'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'betainc'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'betaincinv'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'binom'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'btdtr'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'btdtri'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'btdtria'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'btdtrib'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'cbrt'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'chndtr'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'ellipe'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'ellipeinc'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'ellipj'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'ellipk'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'ellipkinc'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'ellipkm1'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'erf'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'erfc'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'erfcinv'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'erfinv'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'eval_genlaguerre'; maybe "genlaguerre"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'eval_hermite'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'eval_laguerre'; maybe "laguerre"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'eval_legendre'; maybe "legendre"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'exp1'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'expi'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'expm1'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'expn'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gammainc'; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gammaincc'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gammainccinv'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gammaincinv'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gammaln'; maybe "gamma"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gdtr'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gdtrc'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gdtrib'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'gdtrix'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'jn'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'kn'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'log1p'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'lpmv'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'mathieu_cem'; maybe "mathieu_b" or "mathieu_a"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'mathieu_modcem1'; maybe "mathieu_odd_coef"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'mathieu_modcem2'; maybe "mathieu_odd_coef"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'mathieu_modsem1'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'mathieu_modsem2'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'mathieu_sem'; maybe "mathieu_b" or "mathieu_a"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'nbdtrik'; maybe "ndtri"?  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'owens_t'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'pdtrik'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'poch'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'sph_harm'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'wright_bessel'  [attr-defined]
- scipy/special/tests/test_data.py:8: error: Module 'scipy.special' has no attribute 'yn'  [attr-defined]
- scipy/stats/tests/test_contingency.py:6: error: Module 'scipy.special' has no attribute 'xlogy'  [attr-defined]


lookup_typeinfo fails with an AttributeError sometimes if the name we
pass in isn't correct. It's probably easier to just catch all exceptions
than to catch every specific exception that lookup_typeinfo might raise.
mypy/checker.py Outdated
info = self.lookup_typeinfo(expr.fullname)
is_final = info.is_final
# lookup_typeinfo sometimes fails with a KeyError
except Exception:
Copy link
Member

Choose a reason for hiding this comment

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

Catching any Exception isn't great because it can easily mask a bug. If lookup_typeinfo raises an unexpected exception, it might be better to fix that inside the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the changes that you mentioned by not catching all Exceptions. Could you take a look at my changes?

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit.git)
- lib/tests/streamlit/magic_test.py: note: In member "_testCode" of class "MagicTest":
- lib/tests/streamlit/magic_test.py:36:67: error: "AST" has no attribute "func"  [attr-defined]


The test using `is not` to compare the output of type to a class is
testing whether mypy correctly narrows types in the if case, not the
else case (Narrowing in the else case should be the same regardless of
whether the class being compared is final)
Using lookup_typeinfo to get the TypeInfo of a class by name results in
a lot of different exceptions being thrown if what we're passing in
isn't actually the name of a class.

This replaces the use of lookup_typeinfo by using `expr.node` to get
more info about the class that the given name is referring to.
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

streamlit (https://github.com/streamlit/streamlit.git)
- lib/tests/streamlit/magic_test.py: note: In member "_testCode" of class "MagicTest":
- lib/tests/streamlit/magic_test.py:36:67: error: "AST" has no attribute "func"  [attr-defined]


Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Looks good to me but I'd want @JukkaL to do the final review.

@hauntsaninja
Copy link
Collaborator

Not at all blocking, but if you want something related to work on, I think this code still doesn't work after this PR: #10302 (comment)

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the updates and the refactoring! Looks great.


:param node: The node that might contain the comparison

:param expr_indices: The list of indices of expressions in ``node`` that are being compared
Copy link
Collaborator

Choose a reason for hiding this comment

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

Style nit: We generally use this style for documenting arguments:

Args:
    node: The node that might ...
    expr_indiced: The list of indices ...

This is a minor thing, however, and this doesn't block merging this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this change in #10378 because I couldn't figure out how to add more commits to this branch after it's already been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"if type(x) == T" not being used for type narrowing
4 participants