A community-maintained Python framework for creating mathematical animations.
docs: update typing guidelines (#3704)
adeshpande5139765ff435
diff --git a/docs/source/contributing/docs/typings.rst b/docs/source/contributing/docs/typings.rstindex 72891b029..a522b3847 100644--- a/docs/source/contributing/docs/typings.rst+++ b/docs/source/contributing/docs/typings.rst@@ -18,9 +18,7 @@ https://realpython.com/python-type-checking/#hello-types.Typing standards~~~~~~~~~~~~~~~~-Manim uses `mypy`_ to type check its codebase. You will find a list of-configuration values in the ``mypy.ini`` configuration file.-+Manim uses `mypy`_ to type check its codebase. You will find a list of configuration values in the ``mypy.ini`` configuration file.To be able to use the newest typing features not available in the lowestsupported Python version, make use of `typing_extensions`_.@@ -91,6 +89,32 @@ Typing guidelines* Use ``typing.Iterable`` whenever the function works with *any* iterable, not a specific type.+* Prefer ``numpy.typing.NDArray`` over ``numpy.ndarray``++.. code:: py++ import numpy as np++ if TYPE_CHECKING:+ import numpy.typing as npt+++ def foo() -> npt.NDArray[float]:+ return np.array([1, 0, 1])++* If a method returns ``self``, use ``typing_extensions.Self``.++.. code:: py++ if TYPE_CHECKING:+ from typing_extensions import Self+++ class CustomMobject:+ def set_color(self, color: ManimColor) -> Self:+ ...+ return self+* If the function returns a container of a specific length each time, consider using ``tuple`` instead of ``list``... code:: py