Skip to content

ENH: Add a mypy plugin for inferring the precision of np.ctypeslib.c_intp#19062

Merged
charris merged 4 commits intonumpy:mainfrom
BvB93:ctypes-plugin
May 28, 2021
Merged

ENH: Add a mypy plugin for inferring the precision of np.ctypeslib.c_intp#19062
charris merged 4 commits intonumpy:mainfrom
BvB93:ctypes-plugin

Conversation

@BvB93
Copy link
Copy Markdown
Member

@BvB93 BvB93 commented May 21, 2021

Follow up on #19029.

This PR updates numpy's mypy plugin such that it can assign the platform-specific precision of np.ctypeslib.c_intp,
the latter taking one of the following three values: ctypes.c_int, ctypes.c_long or ctypes.c_longlong.

Without the plugin c_intp will default to ctypes.c_int64, which should be the correct type in most cases (i.e. on 64-bit platforms).

Model it after `np.core._internal._getintp_ctype`

Co-Authored-By: Eric Wieser <425260+eric-wieser@users.noreply.github.com>
@charris charris merged commit 336cda1 into numpy:main May 28, 2021
@charris
Copy link
Copy Markdown
Member

charris commented May 28, 2021

Let's give this a shot. Thanks Bas.

@BvB93 BvB93 deleted the ctypes-plugin branch May 28, 2021 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants