Skip to content

__array_namespace__ type Hint #267

Open
@gilfree

Description

@gilfree

I hope this falls under the scope of this repo -

Is there any a way type-hint __array_namespace__? Is it even possible to do so, and it needs to be standardized, or maybe it's not possible with current python type hinting system?

Motivation:

Suppose I want to write a function that will work in multiple conforming libraries, it will probably start with:

xp = x.__array_namespace__()

or, like in NEP-47:

def foo(x,y):
   xp = get_namespace(x,y)

In both cases, I want to be able to type check xp, and have auto-complete on xp in the various IDEs. (At least some auto-complete engines relay on static typing e.g https://github.com/microsoft/pyright)

Is this possible?

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