Skip to content

def has_array_namespace(obj) -> TypeIs[HasNamespace] #19

@jorenham

Description

@jorenham

I'm not sure if has_namespace is the best name for this typeguard, so Suggestions are welcome.

Example implementation that builds #17:

# _namespace.py
from typing_extensions import TypeIs

# --snip--

def has_namespace(obj: object, /) -> TypeIs[HasNamespace[Any]]:
    return hasattr(obj, "__array_namespace__")

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✨ featureIntroduce new features.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions