tadeja commented on code in PR #55264:
URL: https://github.com/apache/arrow/pull/55264#discussion_r4526356079


##########
docs/source/developers/python/development.rst:
##########
@@ -169,6 +181,48 @@ in downstream projects and for users' IDEs.
 Note: ``py.typed`` marker file in the ``pyarrow/`` directory indicates to type
 checkers that PyArrow supports type checking according to :pep:`561`.
 
+Testing Type Stubs
+------------------
+
+The tests in ``pyarrow-stubs/tests/`` pin down the annotated types of public
+APIs. Each check pairs :func:`typing.assert_type`, which every type checker
+verifies statically, with a runtime ``isinstance`` check:
+
+.. code-block:: python
+
+   import pyarrow.lib as lib
+
+   from _check import TYPE_CHECKING_INVALID_USAGE, assert_type, check
+
+   def test_list_type() -> None:
+       lst = lib.list_(lib.int32())
+       check(assert_type(lst, lib.ListType), lib.ListType)
+       check(assert_type(lst.value_type, lib.DataType), lib.DataType)
+
+       if TYPE_CHECKING_INVALID_USAGE:
+           lib.list_(1)  # type: ignore[call-overload]
+
+The type checkers check these files as part of the regular runs above, and
+pytest runs them against the installed PyArrow to make sure the stubs agree
+with what PyArrow actually returns:
+
+.. code-block::
+
+   $ cd arrow/python
+   $ pytest pyarrow-stubs/tests
+
+Run ``pytest`` directly and pass it the directory: ``python -m pytest`` puts
+``arrow/python`` on ``sys.path``, so the source tree would be imported instead
+of the installed PyArrow.

Review Comment:
   @rok commit 82f4e53 updated to a new layout and also removed that incorrect 
part of documentation.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to