Skip to content

BUG: Overloaded return types with np.cross NoReturn leads to type-checking issues #22146

@danielpmorton

Description

@danielpmorton

Describe the issue:

np.cross appears to have a return type of NoReturn when dealing with _ArrayLikeBool_co type, and this NoReturn type is incompatible with type checking in Pylance, and VSCode determines that all code after a call to np.cross is unreachable.

This has been mentioned in a Pylance issue here (microsoft/pylance-release#3195), but they recommended mentioning it with NumPy.

Reproduce the code example:

import numpy as np

x = np.array([1,2,3])
y = np.array([2,3,4])

z = np.cross(x, y)
# This code is determined as unreachable by VSCode due to a NoReturn type
print(z)

Error message:

No response

NumPy/Python version information:

1.23.2 3.9.12 (main, Jun 12 2022, 13:39:05)
[GCC 9.4.0]

Context for the issue:

My code uses np.cross in many places, as well as extensive type-checking. It would be very nice if the return types could be cleaned up to improve compatibility with VSCode/Pylance/Pyright, because right now all of my code is grayed-out

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions