Skip to content

Commit c99cf86

Browse files
authored
DOC: local py.typed for users (#44228)
1 parent 371a8f2 commit c99cf86

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ dist
5050
*.egg-info
5151
.eggs
5252
.pypirc
53+
# type checkers
54+
pandas/py.typed
5355

5456
# tox testing tool
5557
.tox

doc/source/development/contributing_codebase.rst

+20
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,26 @@ A recent version of ``numpy`` (>=1.21.0) is required for type validation.
410410

411411
.. _contributing.ci:
412412

413+
Testing type hints in code using pandas
414+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415+
416+
.. warning::
417+
418+
* Pandas is not yet a py.typed library (:pep:`561`)!
419+
The primary purpose of locally declaring pandas as a py.typed library is to test and
420+
improve the pandas-builtin type annotations.
421+
422+
Until pandas becomes a py.typed library, it is possible to easily experiment with the type
423+
annotations shipped with pandas by creating an empty file named "py.typed" in the pandas
424+
installation folder:
425+
426+
.. code-block:: none
427+
428+
python -c "import pandas; import pathlib; (pathlib.Path(pandas.__path__[0]) / 'py.typed').touch()"
429+
430+
The existence of the py.typed file signals to type checkers that pandas is already a py.typed
431+
library. This makes type checkers aware of the type annotations shipped with pandas.
432+
413433
Testing with continuous integration
414434
-----------------------------------
415435

0 commit comments

Comments
 (0)