8000 Add basic stubs for some class attributes by alanhdu · Pull Request #9 · numpy/numpy-stubs · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Add basic stubs for some class attributes #9

Merged
merged 10 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ctypes typehints
  • Loading branch information
alanhdu committed Feb 15, 2018
commit f6efbfdffd871959116a70f625ca5b25052f2e53
4 changes: 3 additions & 1 deletion numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
from typing import Any, Tuple, Optional

from numpy.core._internal import _ctypes

class dtype: pass
_dtype = dtype # for ndarray type
Copy link
Member

Choose a reason for hiding this comment

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

Give this a name like _dtype_class to make it a little clearer what it is?


Expand Down Expand Up @@ -51,7 +53,7 @@ class ndarray:
ndim: int
shape: Tuple[int, ...]
strides: Tuple[int, ...]
ctypes: Any
ctypes: _ctypes
base: Optional[ndarray]

Copy link
Member

Choose a reason for hiding this comment

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

This list is incomplete for now, so let's add def __getattr__(self, name) -> Any: ....


Expand Down
Empty file added numpy/core/__init__.pyi
Empty file.
21 changes: 21 additions & 0 deletions numpy/core/_internal.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Any

# TODO: add better annotations when ctypes is stubbed out

class _ctypes:
@property
def data(self) -> int: ...

@property
def shape(self) -> Any: ...

@property
def strides(self) -> Any: ...

def data_as(self, obj: Any) -> Any: ...
def shape_as(self, obj: Any) -> Any: ...
def strides_as(self, obj: Any) -> Any: ...
def get_data(self) -> int: ...
def get_shape(self) -> Any: ...
def get_strides(self) -> Any: ...
def get_as_parameter(self) -> Any: ...
0