Loading MANIFEST.in +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ recursive-include extensions * recursive-include docs * recursive-include mypy/typeshed *.py *.pyi recursive-include mypy/xml *.xsd *.xslt *.css recursive-include mypyc/lib-rt *.c *.h include mypy_bootstrap.ini include mypy_self_check.ini include LICENSE PKG-INFO +1 −1 Original line number Diff line number Diff line Metadata-Version: 2.1 Name: mypy Version: 0.730 Version: 0.740 Summary: Optional static typing for Python Home-page: http://www.mypy-lang.org/ Author: Jukka Lehtosalo Loading docs/source/additional_features.rst +17 −16 Original line number Diff line number Diff line Loading @@ -9,9 +9,10 @@ of the previous sections. Dataclasses *********** In Python 3.7, a new ``dataclasses`` module has been added to the standard library. In Python 3.7, a new :py:mod:`dataclasses` module has been added to the standard library. This module allows defining and customizing simple boilerplate-free classes. They can be defined using the ``@dataclasses.dataclass`` decorator: They can be defined using the :py:func:`@dataclasses.dataclass <python:dataclasses.dataclass>` decorator: .. code-block:: python Loading @@ -25,7 +26,7 @@ They can be defined using the ``@dataclasses.dataclass`` decorator: test = Application("Testing...") # OK bad = Application("Testing...", "with plugin") # Error: List[str] expected Mypy will detect special methods (such as ``__lt__``) depending on the flags used to Mypy will detect special methods (such as :py:meth:`__lt__ <object.__lt__>`) depending on the flags used to define dataclasses. For example: .. code-block:: python Loading Loading @@ -65,16 +66,16 @@ class can be used: val = unbox(BoxedData(42, "<important>")) # OK, inferred type is int For more information see `official docs <https://docs.python.org/3/library/dataclasses.html>`_ and `PEP 557 <https://www.python.org/dev/peps/pep-0557/>`_. For more information see :doc:`official docs <python:library/dataclasses>` and :pep:`557`. Caveats/Known Issues ==================== Some functions in the ``dataclasses`` module, such as ``replace()`` and ``asdict()``, Some functions in the :py:mod:`dataclasses` module, such as :py:func:`~dataclasses.replace` and :py:func:`~dataclasses.asdict`, have imprecise (too permissive) types. This will be fixed in future releases. Mypy does not yet recognize aliases of ``dataclasses.dataclass``, and will Mypy does not yet recognize aliases of :py:func:`dataclasses.dataclass <dataclasses.dataclass>`, and will probably never recognize dynamically computed decorators. The following examples do **not** work: Loading Loading @@ -110,7 +111,7 @@ do **not** work: The attrs package ***************** `attrs <http://www.attrs.org/en/stable>`_ is a package that lets you define :doc:`attrs <attrs:index>` is a package that lets you define classes without writing boilerplate code. Mypy can detect uses of the package and will generate the necessary method definitions for decorated classes using the type annotations it finds. Loading Loading @@ -139,7 +140,7 @@ If you're using ``auto_attribs=True`` you must use variable annotations. three: int = attr.ib(8) Typeshed has a couple of "white lie" annotations to make type checking easier. ``attr.ib`` and ``attr.Factory`` actually return objects, but the easier. :py:func:`attr.ib` and :py:class:`attr.Factory` actually return objects, but the annotation says these return the types that they expect to be assigned to. That enables this to work: Loading Loading @@ -174,9 +175,9 @@ Caveats/Known Issues * Currently, ``converter`` only supports named functions. If mypy finds something else it will complain about not understanding the argument and the type annotation in ``__init__`` will be replaced by ``Any``. :py:meth:`__init__ <object.__init__>` will be replaced by ``Any``. * `Validator decorators <http://www.attrs.org/en/stable/examples.html#validators>`_ * :ref:`Validator decorators <attrs:examples_validators>` and `default decorators <http://www.attrs.org/en/stable/examples.html#defaults>`_ are not type-checked against the attribute they are setting/validating. Loading Loading @@ -347,16 +348,16 @@ Extended Callable types This feature is deprecated. You can use :ref:`callback protocols <callback_protocols>` as a replacement. As an experimental mypy extension, you can specify ``Callable`` types As an experimental mypy extension, you can specify :py:data:`~typing.Callable` types that support keyword arguments, optional arguments, and more. When you specify the arguments of a Callable, you can choose to supply just you specify the arguments of a :py:data:`~typing.Callable`, you can choose to supply just the type of a nameless positional argument, or an "argument specifier" representing a more complicated form of argument. This allows one to more closely emulate the full range of possibilities given by the ``def`` statement in Python. As an example, here's a complicated function definition and the corresponding ``Callable``: corresponding :py:data:`~typing.Callable`: .. code-block:: python Loading Loading @@ -433,7 +434,7 @@ purpose: In all cases, the ``type`` argument defaults to ``Any``, and if the ``name`` argument is omitted the argument has no name (the name is required for ``NamedArg`` and ``DefaultNamedArg``). A basic ``Callable`` such as :py:data:`~typing.Callable` such as .. code-block:: python Loading @@ -445,7 +446,7 @@ is equivalent to the following: MyFunc = Callable[[Arg(int), Arg(str), Arg(int)], float] A ``Callable`` with unspecified argument types, such as A :py:data:`~typing.Callable` with unspecified argument types, such as .. code-block:: python Loading docs/source/builtin_types.rst +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ Type Description ====================== =============================== The type ``Any`` and type constructors such as ``List``, ``Dict``, ``Iterable`` and ``Sequence`` are defined in the ``typing`` module. ``Iterable`` and ``Sequence`` are defined in the :py:mod:`typing` module. The type ``Dict`` is a *generic* class, signified by type arguments within ``[...]``. For example, ``Dict[int, str]`` is a dictionary from integers to Loading @@ -35,6 +35,6 @@ strings and ``Dict[Any, Any]`` is a dictionary of dynamically typed correspond to Python protocols. For example, a ``str`` object or a ``List[str]`` object is valid when ``Iterable[str]`` or ``Sequence[str]`` is expected. Note that even though they are similar to abstract base classes defined in ``collections.abc`` they are similar to abstract base classes defined in :py:mod:`collections.abc` (formerly ``collections``), they are not identical, since the built-in collection type objects do not support indexing. docs/source/casts.rst +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ Casts and type assertions Mypy supports type casts that are usually used to coerce a statically typed value to a subtype. Unlike languages such as Java or C#, however, mypy casts are only used as hints for the type checker, and they don't perform a runtime type check. Use the function ``cast`` to perform a don't perform a runtime type check. Use the function :py:func:`~typing.cast` to perform a cast: .. code-block:: python Loading Loading
MANIFEST.in +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ recursive-include extensions * recursive-include docs * recursive-include mypy/typeshed *.py *.pyi recursive-include mypy/xml *.xsd *.xslt *.css recursive-include mypyc/lib-rt *.c *.h include mypy_bootstrap.ini include mypy_self_check.ini include LICENSE
PKG-INFO +1 −1 Original line number Diff line number Diff line Metadata-Version: 2.1 Name: mypy Version: 0.730 Version: 0.740 Summary: Optional static typing for Python Home-page: http://www.mypy-lang.org/ Author: Jukka Lehtosalo Loading
docs/source/additional_features.rst +17 −16 Original line number Diff line number Diff line Loading @@ -9,9 +9,10 @@ of the previous sections. Dataclasses *********** In Python 3.7, a new ``dataclasses`` module has been added to the standard library. In Python 3.7, a new :py:mod:`dataclasses` module has been added to the standard library. This module allows defining and customizing simple boilerplate-free classes. They can be defined using the ``@dataclasses.dataclass`` decorator: They can be defined using the :py:func:`@dataclasses.dataclass <python:dataclasses.dataclass>` decorator: .. code-block:: python Loading @@ -25,7 +26,7 @@ They can be defined using the ``@dataclasses.dataclass`` decorator: test = Application("Testing...") # OK bad = Application("Testing...", "with plugin") # Error: List[str] expected Mypy will detect special methods (such as ``__lt__``) depending on the flags used to Mypy will detect special methods (such as :py:meth:`__lt__ <object.__lt__>`) depending on the flags used to define dataclasses. For example: .. code-block:: python Loading Loading @@ -65,16 +66,16 @@ class can be used: val = unbox(BoxedData(42, "<important>")) # OK, inferred type is int For more information see `official docs <https://docs.python.org/3/library/dataclasses.html>`_ and `PEP 557 <https://www.python.org/dev/peps/pep-0557/>`_. For more information see :doc:`official docs <python:library/dataclasses>` and :pep:`557`. Caveats/Known Issues ==================== Some functions in the ``dataclasses`` module, such as ``replace()`` and ``asdict()``, Some functions in the :py:mod:`dataclasses` module, such as :py:func:`~dataclasses.replace` and :py:func:`~dataclasses.asdict`, have imprecise (too permissive) types. This will be fixed in future releases. Mypy does not yet recognize aliases of ``dataclasses.dataclass``, and will Mypy does not yet recognize aliases of :py:func:`dataclasses.dataclass <dataclasses.dataclass>`, and will probably never recognize dynamically computed decorators. The following examples do **not** work: Loading Loading @@ -110,7 +111,7 @@ do **not** work: The attrs package ***************** `attrs <http://www.attrs.org/en/stable>`_ is a package that lets you define :doc:`attrs <attrs:index>` is a package that lets you define classes without writing boilerplate code. Mypy can detect uses of the package and will generate the necessary method definitions for decorated classes using the type annotations it finds. Loading Loading @@ -139,7 +140,7 @@ If you're using ``auto_attribs=True`` you must use variable annotations. three: int = attr.ib(8) Typeshed has a couple of "white lie" annotations to make type checking easier. ``attr.ib`` and ``attr.Factory`` actually return objects, but the easier. :py:func:`attr.ib` and :py:class:`attr.Factory` actually return objects, but the annotation says these return the types that they expect to be assigned to. That enables this to work: Loading Loading @@ -174,9 +175,9 @@ Caveats/Known Issues * Currently, ``converter`` only supports named functions. If mypy finds something else it will complain about not understanding the argument and the type annotation in ``__init__`` will be replaced by ``Any``. :py:meth:`__init__ <object.__init__>` will be replaced by ``Any``. * `Validator decorators <http://www.attrs.org/en/stable/examples.html#validators>`_ * :ref:`Validator decorators <attrs:examples_validators>` and `default decorators <http://www.attrs.org/en/stable/examples.html#defaults>`_ are not type-checked against the attribute they are setting/validating. Loading Loading @@ -347,16 +348,16 @@ Extended Callable types This feature is deprecated. You can use :ref:`callback protocols <callback_protocols>` as a replacement. As an experimental mypy extension, you can specify ``Callable`` types As an experimental mypy extension, you can specify :py:data:`~typing.Callable` types that support keyword arguments, optional arguments, and more. When you specify the arguments of a Callable, you can choose to supply just you specify the arguments of a :py:data:`~typing.Callable`, you can choose to supply just the type of a nameless positional argument, or an "argument specifier" representing a more complicated form of argument. This allows one to more closely emulate the full range of possibilities given by the ``def`` statement in Python. As an example, here's a complicated function definition and the corresponding ``Callable``: corresponding :py:data:`~typing.Callable`: .. code-block:: python Loading Loading @@ -433,7 +434,7 @@ purpose: In all cases, the ``type`` argument defaults to ``Any``, and if the ``name`` argument is omitted the argument has no name (the name is required for ``NamedArg`` and ``DefaultNamedArg``). A basic ``Callable`` such as :py:data:`~typing.Callable` such as .. code-block:: python Loading @@ -445,7 +446,7 @@ is equivalent to the following: MyFunc = Callable[[Arg(int), Arg(str), Arg(int)], float] A ``Callable`` with unspecified argument types, such as A :py:data:`~typing.Callable` with unspecified argument types, such as .. code-block:: python Loading
docs/source/builtin_types.rst +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ Type Description ====================== =============================== The type ``Any`` and type constructors such as ``List``, ``Dict``, ``Iterable`` and ``Sequence`` are defined in the ``typing`` module. ``Iterable`` and ``Sequence`` are defined in the :py:mod:`typing` module. The type ``Dict`` is a *generic* class, signified by type arguments within ``[...]``. For example, ``Dict[int, str]`` is a dictionary from integers to Loading @@ -35,6 +35,6 @@ strings and ``Dict[Any, Any]`` is a dictionary of dynamically typed correspond to Python protocols. For example, a ``str`` object or a ``List[str]`` object is valid when ``Iterable[str]`` or ``Sequence[str]`` is expected. Note that even though they are similar to abstract base classes defined in ``collections.abc`` they are similar to abstract base classes defined in :py:mod:`collections.abc` (formerly ``collections``), they are not identical, since the built-in collection type objects do not support indexing.
docs/source/casts.rst +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ Casts and type assertions Mypy supports type casts that are usually used to coerce a statically typed value to a subtype. Unlike languages such as Java or C#, however, mypy casts are only used as hints for the type checker, and they don't perform a runtime type check. Use the function ``cast`` to perform a don't perform a runtime type check. Use the function :py:func:`~typing.cast` to perform a cast: .. code-block:: python Loading