Skip to content

Commit

Permalink
Merge pull request #17843 from BvB93/precision-plugin
Browse files Browse the repository at this point in the history
ENH: Add a mypy plugin for inferring platform-specific `np.number` precisions
  • Loading branch information
rgommers committed Dec 22, 2020
2 parents 557ed6a + 75c532d commit e393b06
Show file tree
Hide file tree
Showing 18 changed files with 696 additions and 368 deletions.
22 changes: 22 additions & 0 deletions doc/release/upcoming_changes/17843.new_feature.rst
@@ -0,0 +1,22 @@
Added a mypy plugin for handling platform-specific `numpy.number` precisions
----------------------------------------------------------------------------

A mypy_ plugin is now available for automatically assigning the (platform-dependent)
precisions of certain `~numpy.number` subclasses, including the likes of
`~numpy.int_`, `~numpy.intp` and `~numpy.longlong`. See the documentation on
:ref:`scalar types <arrays.scalars.built-in>` for a comprehensive overview
of the affected classes.

Note that while usage of the plugin is completely optional, without it the
precision of above-mentioned classes will be inferred as `~typing.Any`.

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

0 comments on commit e393b06

Please sign in to comment.