Loading PKG-INFO +2 −3 Original line number Diff line number Diff line Metadata-Version: 1.1 Name: mypy Version: 0.560 Version: 0.570 Summary: Optional static typing for Python Home-page: http://www.mypy-lang.org/ Author: Jukka Lehtosalo Loading @@ -17,12 +17,11 @@ Description: Mypy -- Optional Static Typing for Python features such as type inference, gradual typing, generics and union types. Platform: POSIX Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: POSIX Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Loading README.md +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ sure you've found a bug please search our issue trackers for a duplicate before filing a new issue: - [mypy tracker](https://github.com/python/mypy/issues) for mypy isues for mypy issues - [typeshed tracker](https://github.com/python/typeshed/issues) for issues with specific modules - [typing tracker](https://github.com/python/typing/issues) Loading docs/source/additional_features.rst +76 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,79 @@ including the following: - inheritance between generic classes - compatibility and subtyping of generic types, including covariance of generic types - ``super()`` .. _attrs_package: The attrs package ***************** `attrs <https://www.attrs.org/en/stable>`_ 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. Type annotations can be added as follows: .. code-block:: python import attr @attr.s class A: one: int = attr.ib() # Variable annotation (Python 3.6+) two = attr.ib() # type: int # Type comment three = attr.ib(type=int) # type= argument If you're using ``auto_attribs=True`` you must use variable annotations. .. code-block:: python import attr @attr.s(auto_attribs=True) class A: one: int two: int = 7 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 annotation says these return the types that they expect to be assigned to. That enables this to work: .. code-block:: python import attr from typing import Dict @attr.s(auto_attribs=True) class A: one: int = attr.ib(8) two: Dict[str, str] = attr.Factory(dict) bad: str = attr.ib(16) # Error: can't assign int to str Caveats/Known Issues ==================== * The detection of attr classes and attributes works by function name only. This means that if you have your own helper functions that, for example, ``return attr.ib()`` mypy will not see them. * All boolean arguments that mypy cares about must be literal ``True`` or ``False``. e.g the following will not work: .. code-block:: python import attr YES = True @attr.s(init=YES) class A: ... * 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``. * `Validator decorators <http://www.attrs.org/en/stable/examples.html#decorator>`_ and `default decorators <http://www.attrs.org/en/stable/examples.html#defaults>`_ are not type-checked against the attribute they are setting/validating. * Method definitions added by mypy currently overwrite any existing method definitions. docs/source/builtin_types.rst +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ Type Description ``bytes`` 8-bit string ``object`` an arbitrary object (``object`` is the common base class) ``List[str]`` list of ``str`` objects ``Tuple[int, int]`` tuple of two ``int``s (``Tuple[()]`` is the empty tuple) ``Tuple[int, int]`` tuple of two ``int`` objects (``Tuple[()]`` is the empty tuple) ``Tuple[int, ...]`` tuple of an arbitrary number of ``int`` objects ``Dict[str, int]`` dictionary from ``str`` keys to ``int`` values ``Iterable[int]`` iterable object containing ints Loading docs/source/command_line.rst +18 −27 Original line number Diff line number Diff line Loading @@ -292,22 +292,11 @@ Here are some more useful flags: - ``--ignore-missing-imports`` suppresses error messages about imports that cannot be resolved (see :ref:`follow-imports` for some examples). - ``--strict-optional`` enables experimental strict checking of ``Optional[...]`` types and ``None`` values. Without this option, mypy doesn't generally check the use of ``None`` values -- they are valid everywhere. See :ref:`strict_optional` for more about this feature. - ``--strict-optional-whitelist`` attempts to suppress strict Optional-related errors in non-whitelisted files. Takes an arbitrary number of globs as the whitelist. This option is intended to be used to incrementally roll out ``--strict-optional`` to a large codebase that already has mypy annotations. However, this flag comes with some significant caveats. It does not suppress all errors caused by turning on ``--strict-optional``, only most of them, so there may still be a bit of upfront work to be done before it can be used in CI. It will also suppress some errors that would be caught in a non-strict-Optional run. Therefore, when using this flag, you should also re-check your code without ``--strict-optional`` to ensure new type errors are not introduced. - ``--strict-optional`` enables strict checking of ``Optional[...]`` types and ``None`` values. Without this option, mypy doesn't generally check the use of ``None`` values -- they are valid everywhere. See :ref:`strict_optional` for more about this feature. This flag will become the default in the near future. - ``--disallow-untyped-defs`` reports an error whenever it encounters a function definition without type annotations. Loading Loading @@ -342,17 +331,19 @@ Here are some more useful flags: .. _incremental: - ``--incremental`` is an experimental option that enables a module cache. When enabled, mypy caches results from previous runs to speed up type checking. Incremental mode can help when most parts of your program haven't changed since the previous mypy run. A companion flag is ``--cache-dir DIR``, which specifies where the cache files are written. By default this is ``.mypy_cache`` in the current directory. While the cache is only read in incremental mode, it is written even in non-incremental mode, in order to "warm" the cache. To disable writing the cache, use ``--cache-dir=/dev/null`` (UNIX) or ``--cache-dir=nul`` (Windows). Cache files belonging to a different mypy version are ignored. - ``--incremental`` enables a module cache, using results from previous runs to speed up type checking. Incremental mode can help when most parts of your program haven't changed since the previous mypy run. - ``--cache-dir DIR`` is a companion flag to ``-incremental``, which specifies where the cache files are written. By default this is ``.mypy_cache`` in the current directory. While the cache is only read in incremental mode, it is written even in non-incremental mode, in order to "warm" the cache. To disable writing the cache, use ``--cache-dir=/dev/null`` (UNIX) or ``--cache-dir=nul`` (Windows). Cache files belonging to a different mypy version are ignored. .. _quick-mode: Loading Loading
PKG-INFO +2 −3 Original line number Diff line number Diff line Metadata-Version: 1.1 Name: mypy Version: 0.560 Version: 0.570 Summary: Optional static typing for Python Home-page: http://www.mypy-lang.org/ Author: Jukka Lehtosalo Loading @@ -17,12 +17,11 @@ Description: Mypy -- Optional Static Typing for Python features such as type inference, gradual typing, generics and union types. Platform: POSIX Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: POSIX Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Loading
README.md +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ sure you've found a bug please search our issue trackers for a duplicate before filing a new issue: - [mypy tracker](https://github.com/python/mypy/issues) for mypy isues for mypy issues - [typeshed tracker](https://github.com/python/typeshed/issues) for issues with specific modules - [typing tracker](https://github.com/python/typing/issues) Loading
docs/source/additional_features.rst +76 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,79 @@ including the following: - inheritance between generic classes - compatibility and subtyping of generic types, including covariance of generic types - ``super()`` .. _attrs_package: The attrs package ***************** `attrs <https://www.attrs.org/en/stable>`_ 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. Type annotations can be added as follows: .. code-block:: python import attr @attr.s class A: one: int = attr.ib() # Variable annotation (Python 3.6+) two = attr.ib() # type: int # Type comment three = attr.ib(type=int) # type= argument If you're using ``auto_attribs=True`` you must use variable annotations. .. code-block:: python import attr @attr.s(auto_attribs=True) class A: one: int two: int = 7 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 annotation says these return the types that they expect to be assigned to. That enables this to work: .. code-block:: python import attr from typing import Dict @attr.s(auto_attribs=True) class A: one: int = attr.ib(8) two: Dict[str, str] = attr.Factory(dict) bad: str = attr.ib(16) # Error: can't assign int to str Caveats/Known Issues ==================== * The detection of attr classes and attributes works by function name only. This means that if you have your own helper functions that, for example, ``return attr.ib()`` mypy will not see them. * All boolean arguments that mypy cares about must be literal ``True`` or ``False``. e.g the following will not work: .. code-block:: python import attr YES = True @attr.s(init=YES) class A: ... * 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``. * `Validator decorators <http://www.attrs.org/en/stable/examples.html#decorator>`_ and `default decorators <http://www.attrs.org/en/stable/examples.html#defaults>`_ are not type-checked against the attribute they are setting/validating. * Method definitions added by mypy currently overwrite any existing method definitions.
docs/source/builtin_types.rst +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ Type Description ``bytes`` 8-bit string ``object`` an arbitrary object (``object`` is the common base class) ``List[str]`` list of ``str`` objects ``Tuple[int, int]`` tuple of two ``int``s (``Tuple[()]`` is the empty tuple) ``Tuple[int, int]`` tuple of two ``int`` objects (``Tuple[()]`` is the empty tuple) ``Tuple[int, ...]`` tuple of an arbitrary number of ``int`` objects ``Dict[str, int]`` dictionary from ``str`` keys to ``int`` values ``Iterable[int]`` iterable object containing ints Loading
docs/source/command_line.rst +18 −27 Original line number Diff line number Diff line Loading @@ -292,22 +292,11 @@ Here are some more useful flags: - ``--ignore-missing-imports`` suppresses error messages about imports that cannot be resolved (see :ref:`follow-imports` for some examples). - ``--strict-optional`` enables experimental strict checking of ``Optional[...]`` types and ``None`` values. Without this option, mypy doesn't generally check the use of ``None`` values -- they are valid everywhere. See :ref:`strict_optional` for more about this feature. - ``--strict-optional-whitelist`` attempts to suppress strict Optional-related errors in non-whitelisted files. Takes an arbitrary number of globs as the whitelist. This option is intended to be used to incrementally roll out ``--strict-optional`` to a large codebase that already has mypy annotations. However, this flag comes with some significant caveats. It does not suppress all errors caused by turning on ``--strict-optional``, only most of them, so there may still be a bit of upfront work to be done before it can be used in CI. It will also suppress some errors that would be caught in a non-strict-Optional run. Therefore, when using this flag, you should also re-check your code without ``--strict-optional`` to ensure new type errors are not introduced. - ``--strict-optional`` enables strict checking of ``Optional[...]`` types and ``None`` values. Without this option, mypy doesn't generally check the use of ``None`` values -- they are valid everywhere. See :ref:`strict_optional` for more about this feature. This flag will become the default in the near future. - ``--disallow-untyped-defs`` reports an error whenever it encounters a function definition without type annotations. Loading Loading @@ -342,17 +331,19 @@ Here are some more useful flags: .. _incremental: - ``--incremental`` is an experimental option that enables a module cache. When enabled, mypy caches results from previous runs to speed up type checking. Incremental mode can help when most parts of your program haven't changed since the previous mypy run. A companion flag is ``--cache-dir DIR``, which specifies where the cache files are written. By default this is ``.mypy_cache`` in the current directory. While the cache is only read in incremental mode, it is written even in non-incremental mode, in order to "warm" the cache. To disable writing the cache, use ``--cache-dir=/dev/null`` (UNIX) or ``--cache-dir=nul`` (Windows). Cache files belonging to a different mypy version are ignored. - ``--incremental`` enables a module cache, using results from previous runs to speed up type checking. Incremental mode can help when most parts of your program haven't changed since the previous mypy run. - ``--cache-dir DIR`` is a companion flag to ``-incremental``, which specifies where the cache files are written. By default this is ``.mypy_cache`` in the current directory. While the cache is only read in incremental mode, it is written even in non-incremental mode, in order to "warm" the cache. To disable writing the cache, use ``--cache-dir=/dev/null`` (UNIX) or ``--cache-dir=nul`` (Windows). Cache files belonging to a different mypy version are ignored. .. _quick-mode: Loading