Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19062 from BvB93/ctypes-plugin
ENH: Add a mypy plugin for inferring the precision of `np.ctypeslib.c_intp`
- Loading branch information
Showing
8 changed files
with
96 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Assign the platform-specific ``c_intp`` precision via a mypy plugin | ||
------------------------------------------------------------------- | ||
|
||
The mypy_ plugin, introduced in `numpy/numpy#17843`_, has again been expanded: | ||
the plugin now is now responsible for setting the platform-specific precision | ||
of `numpy.ctypeslib.c_intp`, the latter being used as data type for various | ||
`numpy.ndarray.ctypes` attributes. | ||
|
||
Without the plugin, aforementioned type will default to `ctypes.c_int64`. | ||
|
||
To enable the plugin, one must add it to their mypy `configuration file`_: | ||
|
||
.. code-block:: ini | ||
[mypy] | ||
plugins = numpy.typing.mypy_plugin | ||
.. _mypy: http://mypy-lang.org/ | ||
.. _configuration file: https://mypy.readthedocs.io/en/stable/config_file.html | ||
.. _`numpy/numpy#17843`: https://github.com/numpy/numpy/pull/17843 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import numpy as np | ||
|
||
reveal_type(np.ctypeslib.c_intp()) # E: {c_intp} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters