{ "info": { "author": "Joshua Oreman", "author_email": "oremanj@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Trio", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: BSD", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": ".. image:: https://img.shields.io/pypi/v/trio-typing.svg\n :target: https://pypi.org/project/trio-typing\n :alt: Latest PyPI version\n\n.. image:: https://travis-ci.org/python-trio/trio-typing.svg?branch=master\n :target: https://travis-ci.org/python-trio/trio-typing\n :alt: Automated test status\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/ambv/black\n :alt: Code style: black\n\n.. image:: http://www.mypy-lang.org/static/mypy_badge.svg\n :target: http://www.mypy-lang.org/\n :alt: Checked with mypy\n\ntrio-typing: static typing for Trio and related projects\n========================================================\n\nThis repository provides:\n\n* PEP 561 typing stubs packages for the Trio project packages:\n\n * `trio `__ (``trio-stubs``)\n\n * `outcome `__ (``outcome-stubs``)\n\n * `async_generator `__\n (``async_generator-stubs``)\n\n* A package ``trio_typing`` containing types that Trio programs often want\n to refer to (``AsyncGenerator[Y, S]`` and ``TaskStatus[T]``) and a mypy\n plugin that smooths over some limitations in the basic type hints.\n (``Nursery`` is exported publicly by mainline Trio as of version 0.12.0.)\n\n\nSupported platforms\n~~~~~~~~~~~~~~~~~~~\n\nTo **type-check** code that uses ``trio-typing``, you need CPython 3.5.2\nor later. (Mypy requires 3.5.2+, and its dependency ``typed-ast``\ndoesn't support PyPy.) We test on Linux using the latest releases\nfrom the 3.5, 3.6, and 3.7 branches, as well as 3.8-dev nightly. We're\nnot knowingly doing anything OS-specific, so other OSes should work\ntoo.\n\nYou can **run** code that uses ``trio-typing`` on any platform\nsupported by Trio, includng PyPy and CPython 3.5.0 and 3.5.1.\n\nType checkers other than Mypy are not supported, but might work.\nExperience reports and patches to add support are welcome.\n\n\nQuickstart\n~~~~~~~~~~\n\nInstall with::\n\n pip install -U trio-typing\n\nEnable the plugin in your ``mypy.ini`` (optional, but recommended)::\n\n [mypy]\n plugins = trio_typing.plugin\n\nStart running mypy on your Trio code! You may want to import some typing\nnames from ``trio_typing``, like ``TaskStatus``; see below\nfor more details.\n\n\nWhat's in the box?\n~~~~~~~~~~~~~~~~~~\n\nThe stubs packages provide types for all public non-deprecated APIs of\n``trio``, ``outcome``, and ``async_generator``, as of the release date\nof the corresponding ``trio-typing`` distribution. You don't need to\nexplicitly configure these; just say ``import trio`` (for example)\nand mypy will know to look in ``trio-stubs`` for the type information.\n\nThe ``trio_typing`` package provides:\n\n* ``TaskStatus[T]``, the type of the object passed as the ``task_status``\n argument to a task started with ``nursery.start()``. The type parameter\n ``T`` is the type of the value the task provides to be returned from\n ``nursery.start()``. This is implemented as an ABC, and the actual\n private types inside Trio are registered as virtual subclasses\n of it. So, you can't instantiate ``trio_typing.TaskStatus``, but\n ``isinstance(task_status, trio_typing.TaskStatus)`` where ``task_status``\n is a Trio task status object does return True.\n\n* (Previous versions of ``trio_typing`` provided an analogous ABC for\n ``Nursery``, but the actual class is available as ``trio.Nursery`` as of\n Trio 0.12.0; you should use that instead.)\n\n* A backport of ``typing.AsyncGenerator[YieldT, SendT]`` to Python 3.5.\n (``YieldT`` is the type of values yielded by the generator, and\n ``SendT`` is the type of values it accepts as an argument to ``asend()``.)\n This is an abstract class describing the async generator interface:\n ``AsyncIterator`` plus ``asend``, ``athrow``, ``aclose``, and the\n ``ag_*`` introspection attributes. On 3.6+, ``trio_typing.AsyncGenerator``\n is just a reexport of ``typing.AsyncGenerator``.\n\n* ``CompatAsyncGenerator[YieldT, SendT, ReturnT]``,\n a name for the otherwise-anonymous concrete async generator type\n returned by ``@async_generator`` functions. It is a subtype of\n ``AsyncGenerator[YieldT, SendT]`` and provides the same methods.\n (Native async generators don't have a ``ReturnT``; it is only relevant\n in determining the return type of ``await async_generator.yield_from_()``.)\n\n* A few types that are only useful with the mypy plugin: ``YieldType[T]``,\n ``SendType[T]``, and the decorator ``@takes_callable_and_args``.\n\nThe ``trio_typing.plugin`` mypy plugin provides:\n\n* Argument type checking for functions decorated with\n ``@asynccontextmanager`` (either the one in ``async_generator`` or the\n one in 3.7+ ``contextlib``) and ``@async_generator``\n\n* Inference of more specific ``trio.open_file()`` and ``trio.Path.open()``\n return types based on constant ``mode`` and ``buffering`` arguments, so\n ``await trio.open_file(\"foo\", \"rb\", 0)`` returns an unbuffered async\n file object in binary mode and ``await trio.open_file(\"bar\")`` returns\n an async file object in text mode\n\n* Signature checking for ``task_status.started()`` with no arguments,\n so it raises an error if the ``task_status`` object is not of type\n ``TaskStatus[None]``\n\n* Boilerplate reduction for functions that take parameters ``(fn, *args)``\n and ultimately invoke ``fn(*args)``: just write::\n\n from mypy_extensions import VarArg\n\n @trio_typing.takes_callable_and_args\n def start_soon(\n async_fn: Callable[[VarArg()], Awaitable[T]],\n *args: Any,\n other_keywords: str = are_ok_too,\n ):\n # your implementation here\n\n ``start_soon(async_fn, *args)`` will raise an error if ``async_fn(*args)``\n would do so. You can also make the callable take some non-splatted\n arguments; the ``*args`` get inserted at whatever position in the\n argument list you write ``VarArg()``.\n\n The above example will always fail when the plugin is not being\n used. If you want to always pass in such cases, you can use a union::\n\n @trio_typing.takes_callable_and_args\n def start_soon(\n async_fn: Union[\n Callable[..., Awaitable[T]],\n Callable[[VarArg()], Awaitable[T]],\n ],\n *args: Any,\n other_keywords: str = are_ok_too,\n ):\n # your implementation here\n\n Without the plugin, this type-checks fine (and allows inference of\n ``T``), since any callable will match the ``Callable[...,\n Awaitable[T]]`` option. With the plugin, the entire union will be\n replaced with specific argument types.\n\n Note: due to mypy limitations, we only support a maximum of 5\n positional arguments, and keyword arguments can't be passed in this way;\n ``nursery.start_soon(functools.partial(...))`` will pass the type checker\n but won't be able to actually check the argument types.\n\n* Mostly-full support for type checking ``@async_generator`` functions.\n You write the decorated function as if it returned a union of its actual\n return type, its yield type wrapped in ``YieldType[]``, and its send\n type wrapped in ``SendType[]``::\n\n from trio_typing import YieldType, SendType\n @async_generator\n async def sleep_and_sqrt() -> Union[None, SendType[int], YieldType[float]]:\n next_yield = 0.0\n while True:\n amount = await yield_(next_yield) # amount is an int\n if amount < 0:\n return None\n await trio.sleep(amount)\n next_yield = math.sqrt(amount)\n\n # prints: CompatAsyncGenerator[float, int, None]\n reveal_type(sleep_and_sqrt())\n\n Calls to ``yield_`` and ``yield_from_`` inside an ``@async_generator``\n function are type-checked based on these declarations. If you leave\n off *either* the yield type or send type, the missing one is assumed\n to be ``None``; if you leave off *both* (writing just\n ``async def sleep_and_sqrt() -> None:``, like you would if you weren't\n using the plugin), they're both assumed to be ``Any``.\n\n Note the explicit ``return None``; mypy won't accept ``return`` or\n falling off the end of the function, unless you run it with\n ``--no-warn-no-return``.\n\n\nLimitations\n~~~~~~~~~~~\n\n* Calls to variadic Trio functions like ``trio.run()``,\n ``nursery.start_soon()``, and so on, only can type-check up to five\n positional arguments. (This number could be increased easily, but\n only at the cost of slower typechecking for everyone; mypy's current\n architecture requires that we generate overload sets initially for\n every arity we want to be able to use.) You can work around this with\n a ``# type: ignore`` comment.\n\n* ``outcome.capture()`` and ``outcome.acapture()`` currently don't typecheck\n their arguments at all.\n\n\nRunning the tests\n~~~~~~~~~~~~~~~~~\n\n``trio-typing`` comes with a fairly extensive testsuite; it doesn't test all\nthe mechanical parts of the stubs, but does exercise most of the interesting\nplugin behavior. You can run it after installing, with::\n\n pytest -p trio_typing._tests.datadriven --pyargs trio_typing\n\n\nLicense\n~~~~~~~\n\nYour choice of MIT or Apache 2.0.\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/python-trio/trio-typing", "keywords": "async,trio,mypy", "license": "MIT -or- Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "trio-typing", "package_url": "https://pypi.org/project/trio-typing/", "platform": "", "project_url": "https://pypi.org/project/trio-typing/", "project_urls": { "Homepage": "https://github.com/python-trio/trio-typing" }, "release_url": "https://pypi.org/project/trio-typing/0.3.0/", "requires_dist": [ "trio (>=0.12.1)", "typing-extensions (>=3.7.4)", "mypy-extensions (>=0.4.2)", "mypy (>=0.740) ; implementation_name == \"cpython\"" ], "requires_python": "", "summary": "Static type checking support for Trio and related projects", "version": "0.3.0" }, "last_serial": 5987415, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e8df0fd425255bc95b89d291dd76edc9", "sha256": "e8f6dcf2783fe1399cb30930ca0c1c63beb14b3499c7baead54db6e775afee55" }, "downloads": -1, "filename": "trio_typing-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e8df0fd425255bc95b89d291dd76edc9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 37417, "upload_time": "2019-02-11T00:29:25", "url": "https://files.pythonhosted.org/packages/a2/80/dac6c6cb34608fac9c1cc2e4011205bf7709135c30ccfe18a1187ce73060/trio_typing-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "53c7c43e30dfbc0d5ab3c46cc60d7854", "sha256": "27500e3d4672798233091e59824c4ca456ab4e30d4b33c311bd6cc9201aaeb82" }, "downloads": -1, "filename": "trio-typing-0.1.0.tar.gz", "has_sig": false, "md5_digest": "53c7c43e30dfbc0d5ab3c46cc60d7854", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31255, "upload_time": "2019-02-11T00:29:27", "url": "https://files.pythonhosted.org/packages/42/03/95358219b76c25dd3100a3a5fb5ac9d889ac20c8f6ddc14249c6797f20d0/trio-typing-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "7d6a91e0f6832fb2114478bc6c01b921", "sha256": "ba25d019626c5e00bb2e665cedc302afe94517fe71ebcbaecdc02a87083628f3" }, "downloads": -1, "filename": "trio_typing-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7d6a91e0f6832fb2114478bc6c01b921", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 39609, "upload_time": "2019-02-19T06:17:00", "url": "https://files.pythonhosted.org/packages/9d/0b/a4eca15c316fbaef489758a0f47387ae9ec1fc36d3fce94b6f389d5b1d5b/trio_typing-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1deff6411ebc001bc1d7070e087b92eb", "sha256": "bdbba505d2ae5582438721109647a09e6f8a502b10093046c41ae7c79a560050" }, "downloads": -1, "filename": "trio-typing-0.2.0.tar.gz", "has_sig": false, "md5_digest": "1deff6411ebc001bc1d7070e087b92eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34679, "upload_time": "2019-02-19T06:17:02", "url": "https://files.pythonhosted.org/packages/3b/61/76628a84c75a77969b2c762f1b4dc445704254f21575e1e1fed8562e319d/trio-typing-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "616645fb06f47fcc9d3549385a59eb42", "sha256": "33fd8acd4f2dadf1ebb443504a890ae138c2e5b0ebde93474a04c4c1a00c73d6" }, "downloads": -1, "filename": "trio_typing-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "616645fb06f47fcc9d3549385a59eb42", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 40894, "upload_time": "2019-10-17T03:54:47", "url": "https://files.pythonhosted.org/packages/63/e6/321586c195b2dc659ebd4be1c90814f608255083153ca156d8f5d370c8d8/trio_typing-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d6eafc9d63afd866e6a1c1b974a9a47", "sha256": "d242fcab48437be1500b55b13973fbca93cf78ff6b940ba71b87c618248d6bfa" }, "downloads": -1, "filename": "trio-typing-0.3.0.tar.gz", "has_sig": false, "md5_digest": "2d6eafc9d63afd866e6a1c1b974a9a47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35866, "upload_time": "2019-10-17T03:54:50", "url": "https://files.pythonhosted.org/packages/2c/49/2e970217f1740fdb57a8bbb5d4cdd5a5d71a9047b75976ca68f094720368/trio-typing-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "616645fb06f47fcc9d3549385a59eb42", "sha256": "33fd8acd4f2dadf1ebb443504a890ae138c2e5b0ebde93474a04c4c1a00c73d6" }, "downloads": -1, "filename": "trio_typing-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "616645fb06f47fcc9d3549385a59eb42", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 40894, "upload_time": "2019-10-17T03:54:47", "url": "https://files.pythonhosted.org/packages/63/e6/321586c195b2dc659ebd4be1c90814f608255083153ca156d8f5d370c8d8/trio_typing-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d6eafc9d63afd866e6a1c1b974a9a47", "sha256": "d242fcab48437be1500b55b13973fbca93cf78ff6b940ba71b87c618248d6bfa" }, "downloads": -1, "filename": "trio-typing-0.3.0.tar.gz", "has_sig": false, "md5_digest": "2d6eafc9d63afd866e6a1c1b974a9a47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35866, "upload_time": "2019-10-17T03:54:50", "url": "https://files.pythonhosted.org/packages/2c/49/2e970217f1740fdb57a8bbb5d4cdd5a5d71a9047b75976ca68f094720368/trio-typing-0.3.0.tar.gz" } ] }