{
"info": {
"author": "Stefan Richthofer",
"author_email": "stefan.richthofer@jyni.org",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6"
],
"description": ".. Copyright 2017, 2018 Stefan Richthofer\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n.. image:: https://travis-ci.org/Stewori/pytypes.svg?branch=master\n :target: https://travis-ci.org/Stewori/pytypes\n :alt: Build Status\n\n.. image:: https://raw.githubusercontent.com/Stewori/pytypes/master/pytypes_logo_text.png\n :scale: 70%\n :align: left\n :alt: pytypes\n\n\nWelcome to the pytypes project\n==============================\n\npytypes is a typing toolbox w.r.t. `PEP\n484 `__ (PEP\n`526 `__ on the road map,\nlater also `544 `__ if it\ngets accepted).\n\nIt's main features are currently\n\n- ``@typechecked`` decorator for runtime typechecking with support for `stubfiles `__ and `type comments `__\n- ``@override`` decorator that asserts existence of a type-compatible parent method\n- ``@annotations`` decorator to turn type info from stubfiles or from type comments into ``__annotations__``\n- ``@typelogged`` decorator observes function and method calls at runtime and generates stubfiles from acquired type info\n- service functions to apply these decorators module wide or even globally, i.e. runtime wide\n- typechecking can alternatively be done in decorator-free manner (friendlier for debuggers)\n- all the above decorators work smoothly with OOP, i.e. with methods, static methods, class methods and properties, even if classes are nested\n- converter for stubfiles to Python 2.7 compliant form\n- lots of utility functions regarding types, e.g. a Python 2.7 compliant and actually functional implementation of ``get_type_hints``\n- full Python 2.7 support for all these features\n\nAn additional future goal will be integration with the Java typing system when running on Jython. Along with this, some generator utilities to produce type-safe Java bindings for Python frameworks are planned.\n\nIn wider sense, PEP 484-style type annotations can be used to build type safe interfaces to allow also other programming languages to call into Python code (kind of reverse FFI). In this sense the project name refers to 'ctypes', which provides Python-bindings of C.\n\n\nPython 2.7, 3.5, 3.6\n--------------------\n\nAll described features of pytypes were carefully implemented such that they are equally workable on CPython 3.5, 3.6, 2.7 and on Jython 2.7.1 (other interpreters might work as well, but were not yet tested).\nFor Python 2.7, pytypes fully supports type-annotations via `type comments `__.\nIt also supports Python 2.7-style type annotations in Python 3.5-code to allow easier 2.7/3.5 multi-version development.\n\n\nWhy write another runtime typecheck decorator?\n----------------------------------------------\n\nThere have been earlier approaches for runtime-typechecking. However, most of them predate PEP 484 or lack some crucial features like support of Python 2.7 or support of stubfiles. Also, none of them features a typechecking override decorator. There were separate approaches for override decorators, but these usually don't consider PEP 484 at all. So we decided that it's time for a new runtime typechecking framework, designed to support PEP 484 from the roots, including its extensive features like (Python 2.7-style-)type comments and stub files.\n\n\nQuick manual\n============\n\n\nTypechecking\n------------\n\npytypes provides a rich set of utilities for runtime typechecking.\n\n@typechecked decorator\n~~~~~~~~~~~~~~~~~~~~~~\n\nDecorator applicable to functions, methods, properties and classes.\nAsserts compatibility of runtime argument and return values of all targeted functions and methods w.r.t. `PEP 484 `__-style type annotations of these functions and methods.\nThis supports `stubfiles `__ and `type comments `__ and is thus workable on Python 2.7.\n\n\nDisabling typechecking\n~~~~~~~~~~~~~~~~~~~~~~\n\nRunning Python with the '-O' flag, which also disables ``assert`` statements, turns off typechecking completely.\nAlternatively, one can modify the flag ``pytypes.checking_enabled``.\n\nNote that this must be done right after import of pytypes, because it affects the way how ``@typechecked`` decorator works. For modules that were imported with this flag disabled, typechecking cannot be turned on later on within the same runtime.\n\n\nUsage Python 2\n~~~~~~~~~~~~~~\n\n.. code:: python\n\n from pytypes import typechecked\n\n @typechecked\n def some_function(a, b, c):\n # type: (int, str, List[Union[str, float]]) -> int\n return a+len(b)+len(c)\n\n\nUsage Python 3\n~~~~~~~~~~~~~~\n\n.. code:: python\n\n from pytypes import typechecked\n\n @typechecked\n def some_function(a: int, b: str, c: List[Union[str, float]]) -> int:\n return a+len(b)+len(c)\n\n\nOverriding methods in type-safe manner\n--------------------------------------\n\nThe decorators in this section allow type-safe method overriding.\n\n@override decorator\n~~~~~~~~~~~~~~~~~~~\n\nDecorator applicable to methods only.\nFor a version applicable also to classes or modules use ``auto_override``.\nAsserts that for the decorated method a parent method exists in its mro.\nIf both the decorated method and its parent method are type annotated, the decorator additionally asserts compatibility of the annotated types.\nNote that the return type is checked in contravariant manner. A successful check guarantees that the child method can always be used in places that support the parent method's signature.\nUse ``pytypes.check_override_at_runtime`` and ``pytypes.check_override_at_class_definition_time`` to control whether checks happen at class definition time or at \"actual runtime\".\n\nThe following rules apply for override checking:\n\n- a parent method must exist\n- the parent method must have call-compatible signature (e.g. same number of args)\n- arg types of parent method must be more or equal specific than arg types of child\n- return type behaves contravariant - parent method must have less or equal specific return type than child\n\n\nUsage Example\n~~~~~~~~~~~~~\n\n.. code:: python\n\n from pytypes import override\n\n class some_baseclass():\n def some_method1(self, a: int) -> None: ...\n def some_method2(self, a: int) -> None: ...\n def some_method3(self, a: int) -> None: ...\n def some_method4(self) -> int: ...\n\n class some_subclass(some_baseclass):\n @override\n def some_method1(self, a: float) -> None: ...\n\n @override\n def some_method2(self, a: str) -> None: ...\n\n @override\n def some_metd3(self, a: int) -> None: ...\n\n @override\n def some_method4(self) -> float: ...\n\n- ``some_method1``: override check passes\n- ``some_method2``: override check fails because type is not compatible\n- ``some_method3``: override check fails because of typo in method name\n- ``some_method4``: override check fails because return type must be more or equal specific than parent\n\n\n@auto_override decorator\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nDecorator applicable to methods and classes.\nWorks like ``override`` decorator on type annotated methods that actually have a type annotated parent method. Has no effect on methods that do not override anything.\nIn contrast to plain ``override`` decorator, ``auto_override`` can be applied easily on every method in a class or module.\nIn contrast to explicit ``override`` decorator, ``auto_override`` is not suitable to detect typos in spelling of a child method's name. It is only useful to assert compatibility of type information (note that return type is contravariant).\nUse ``pytypes.check_override_at_runtime`` and ``pytypes.check_override_at_class_definition_time`` to control whether checks happen at class definition time or at \"actual runtime\".\n\nThe following rules apply, if a parent method exists:\n\n- the parent method must have call-compatible signature (e.g. same number of args)\n- arg types of parent method must be more or equal specific than arg types of child\n- return type behaves contravariant - parent method must have less or equal specific return type than child\n\nCompared to ordinary ``override`` decorator, the rule \u201ca parent method must exist\u201d is not applied here.\nIf no parent method exists, ``auto_override`` silently passes.\n\n\nProvide info from type comments and stubfiles as ``__annotations__`` for other tools\n------------------------------------------------------------------------------------\n\n@annotations decorator\n~~~~~~~~~~~~~~~~~~~~~~\n\nDecorator applicable to functions, methods, properties and classes.\nMethods with type comment will have type hints parsed from that string and get them attached as ``__annotations__`` attribute. Methods with either a type comment or ordinary type annotations in a stubfile will get that information attached as ``__annotations__`` attribute (also a relevant use case in Python 3).\nBehavior in case of collision with previously (manually) attached ``__annotations__`` can be controlled using the flags ``pytypes.annotations_override_typestring`` and ``pytypes.annotations_from_typestring``.\n\n\nType logging\n------------\n\n@typelogged decorator\n~~~~~~~~~~~~~~~~~~~~~\n\nDecorator applicable to functions, methods, properties and classes.\nIt observes function and method calls at runtime and can generate stubfiles from acquired type info.\n\n\nDisabling typelogging\n~~~~~~~~~~~~~~~~~~~~~\n\nOne can disable typelogging via the flag ``pytypes.typelogging_enabled``.\n\nNote that this must be done right after import of pytypes, because it affects the way how ``@typelogged`` decorator works. For modules that were imported with this flag disabled, typelogging cannot be turned on later on within the same runtime.\n\n\nUsage example with decorator\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAssume you run a file ./script.py like this:\n\n.. code:: python\n\n from pytypes import typelogged\n\n @typelogged\n def logtest(a, b, c=7, *var, **kw): return 7, a, b\n\n @typelogged\n class logtest_class(object):\n def logmeth(self, b): return 2*b\n\n @classmethod\n def logmeth_cls(cls, c): return len(c)\n\n @staticmethod\n def logmeth_static(c): return len(c)\n\n @property\n def log_prop(self): return self._log_prop\n\n @log_prop.setter\n def log_prop(self, val): self._log_prop = val\n\n logtest(3, 2, 5, 6, 7, 3.1, y=3.2, x=9)\n logtest(3.5, 7.3, 5, 6, 7, 3.1, y=3.2, x=9)\n logtest('abc', 7.3, 5, 6, 7, 3.1, y=2, x=9)\n lcs = logtest_class()\n lcs.log_prop = (7.8, 'log')\n lcs.log_prop\n logtest_class.logmeth_cls('hijk')\n logtest_class.logmeth_static(range(3))\n\n pytypes.dump_cache()\n\n\nUsage example with profiler\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAlternatively you can use the `TypeLogger` profiler:\n\n.. code:: python\n\n from pytypes import TypeLogger\n\n def logtest(a, b, c=7, *var, **kw): return 7, a, b\n\n class logtest_class(object):\n def logmeth(self, b): return 2*b\n\n @classmethod\n def logmeth_cls(cls, c): return len(c)\n\n @staticmethod\n def logmeth_static(c): return len(c)\n\n @property\n def log_prop(self): return self._log_prop\n\n @log_prop.setter\n def log_prop(self, val): self._log_prop = val\n\n with TypeLogger():\n \tlogtest(3, 2, 5, 6, 7, 3.1, y=3.2, x=9)\n \tlogtest(3.5, 7.3, 5, 6, 7, 3.1, y=3.2, x=9)\n \tlogtest('abc', 7.3, 5, 6, 7, 3.1, y=2, x=9)\n \tlcs = logtest_class()\n \tlcs.log_prop = (7.8, 'log')\n \tlcs.log_prop\n \tlogtest_class.logmeth_cls('hijk')\n \tlogtest_class.logmeth_static(range(3))\n\nNote that this will produce more stubs, i.e. also for indirectly used modules, because\nthe profiler will handle every function call. To scope a specific module at a time use\n`pytypes.typelogged` on that module or its name. This should be called on a\nmodule after it is fully loaded. To use it inside the scoped module (e.g. for `__main__`)\napply it right after all classes and functions are defined.\n\n\nOutput\n~~~~~~\n\nAny of the examples above will create the following file in ./typelogger\\_output:\n\nscript.pyi:\n\n.. code:: python\n\n from typing import Tuple, Union\n\n def logtest(a: Union[float, str], b: float, c: int, *var: float, **kw: Union[float, int]) -> Union[Tuple[int, float, float], Tuple[int, str, float]]: ...\n\n class logtest_class(object):\n def logmeth(self, b: int) -> int: ...\n\n @classmethod\n def logmeth_cls(cls, c: str) -> int: ...\n\n @staticmethod\n def logmeth_static(c: range) -> int: ...\n\n @property\n def log_prop(self) -> Tuple[float, str]: ...\n\n @log_prop.setter\n def log_prop(self, val: Tuple[float, str]) -> None: ...\n\nUse ``pytypes.dump_cache(python2=True)`` to produce a Python 2.7 compliant stubfile.\n\n\nWriting typelog at exit\n~~~~~~~~~~~~~~~~~~~~~~~\n\nBy default, pytypes performs ``pytypes.dump_cache()`` at exit, i.e. writes typelog as a Python 3 style stubfile.\nUse ``pytypes.dump_typelog_at_exit`` to control this behavior.\nUse ``pytypes.dump_typelog_at_exit_python2`` to write typelog as a Python 2 style stubfile.\n\n\nGlobal mode and module wide mode\n--------------------------------\n\nNote that global mode is experimental.\n\nThe pytypes decorators ``@typechecked``, ``@auto_override``, ``@annotations`` and ``@typelogged`` can be applied module wide by explicitly calling them on a module object or a module name contained in ``sys.modules``. In such a case, the decorator is applied to all functions and classes in that module and recursively to all methods, properties and inner classes too.\n\n*Warning: If A decorator is applied to a partly imported module, only functions and classes that were already defined are affected. After the module imported completely, the decorator is applied to the remaining functions and classes. In the meantime, internal code of that module can circumvent the decorator, e.g. can make module-internal calls that are not typechecked.*\n\n\nGlobal mode via profilers\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe pytypes decorators ``@typechecked`` and ``@typelogged`` have corresponding profiler implementations ``TypeChecker`` and ``TypeLogger``.\nYou can conveniently install them globally via ``enable_global_typechecked_profiler()`` and ``enable_global_typelogged_profiler()``.\n\nAlternatively you can apply them in a ``with``-context:\n\n.. code:: python\n\n from pytypes import TypeChecker\n\n def agnt_test(v):\n # type: (str) -> int\n return 67\n\n with TypeChecker():\n agnt_test(12)\n\n\nOne glitch is to consider in case you want to catch ``TypeCheckError`` (i.e. ``ReturnTypeError`` or ``InputTypeError`` as well) and continue execution afterwards. The ``TypeChecker`` would be suspended unless you call ``restore_profiler``, e.g.:\n\n.. code:: python\n\n from pytypes import TypeChecker, restore_profiler\n\n def agnt_test(v):\n # type: (str) -> int\n return 67\n\n with TypeChecker():\n try:\n agnt_test(12)\n except TypeCheckError:\n restore_profiler()\n # handle error....\n\n\nNote that the call to ``restore_profiler`` must be performed by the thread that raised the error.\n\nAlternatively you can enable ``pytypes.warning_mode = True`` to raise warnings rather than errors. (This only helps if you don't use ``filterwarnings(\"error\")`` or likewise.)\n\n\nGlobal mode via decorators\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe pytypes decorators ``@typechecked``, ``@auto_override``, ``@annotations`` and ``@typelogged`` can be applied globally to all loaded modules and subsequently loaded modules.\nModules that were loaded while typechecking or typelogging was disabled will not be affected. Apart from that this will affect every module in the way described above.\nNote that we recommend to use the profilers explained in the previous section if global typechecking or typelogging is required.\nUse this feature with care as it is still experimental and can notably slow down your python runtime. In any case, it is intended for debugging and testing phase only.\n\n- To apply ``@typechecked`` globally, use ``pytypes.set_global_typechecked_decorator``\n- To apply ``@auto_override`` globally, use ``pytypes.set_global_auto_override_decorator``\n- To apply ``@annotations`` globally, use ``pytypes.set_global_annotations_decorator``\n- To apply ``@typelogged`` globally, use ``pytypes.set_global_typelogged_decorator``\n\n*Warning: If the module that performs the ``pytypes.set_global_xy_decorator``-call is not yet fully imported, the warning regarding module-wide decorators (see above) applies to that module in the same sense. I.e. functions and classes that were not yet defined, will be covered only once the module-import has fully completed.*\n\n\nOOP support\n-----------\n\nAll the above decorators work smoothly with OOP. You can safely apply ``@typechecked``, ``@annotations`` and ``@typelogged`` on methods, abstract methods, static methods, class methods and properties.\n``@override`` is \u2013 already by semantics \u2013 only applicable to methods,\n``@auto_override`` is additionally applicable to classes and modules.\n\npytypes also takes care of inner classes and resolves name space properly.\nMake sure to apply decorators from pytypes *on top of* ``@staticmethod``, ``@classmethod``, ``@property`` or ``@abstractmethod`` rather than the other way round. This is because OOP support involves some special treatment internally, so OOP decorators must be visible to pytypes decorators. This also applies to old-style classes.\n\n\nNo @override on ``__init__``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFor now, ``@override`` cannot be applied to ``__init__``, because ``__init__`` typically extends the list of initialization parameters and usually uses ``super`` to explicitly serve a parent's signature.\nThe purpose of ``@override`` is to avoid typos and to guarantee that the child method can always be used as a fill in for the parent in terms of signature and type information. Both aspects are hardly relevant for ``__init__``:\n\n- a typo is unlikely and would show up quickly for various reasons\n- when creating an instance the caller usually knows the exact class to instantiate and thus its signature\n\nFor special cases where this might be relevant, ``@typechecked`` can be used to catch most errors.\n\n\nUtilities\n---------\n\nUtility functions described in this section can be directly imported from the pytypes module. Only the most important utility functions are listed here.\n\n\nget_type_hints(func)\n~~~~~~~~~~~~~~~~~~~~\n\nResembles ``typing.get_type_hints``, but is also workable on Python 2.7 and searches stubfiles for type information. Also on Python 3, this takes `type comments `__ into account if present.\n\n\nget_types(func)\n~~~~~~~~~~~~~~~\n\nWorks like ``get_type_hints``, but returns types as a sequence rather than a dictionary. Types are returned in declaration order of the corresponding arguments.\n\n\ncheck_argument_types(cllable=None, call_args=None, clss=None, caller_level=0)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis function mimics `typeguard `__ syntax and semantics. It can be applied within a function or method to check argument values to comply with type annotations.\nIt behaves similar to ``@typechecked`` except that it is not a decorator and does not check the return type.\nA decorator less way for argument checking yields less interference with some debuggers.\n\n\ncheck_return_type(value, cllable=None, clss=None, caller_level=0)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis function works like ``check_argument_types``, but applies to the return value.\nBecause it is impossible for pytypes to automatically figure out the value to be returned in a function, it must be explicitly provided as the ``value``-parameter.\n\n\nis_of_type(obj, cls, bound_Generic=None)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWorks like ``isinstance``, but supports PEP 484 style types from typing module.\n\nIf ``cls`` contains unbound ``TypeVar`` s and ``bound_Generic`` is provided, this function attempts to\nretrieve corresponding values for the unbound ``TypeVar`` s from ``bound_Generic``.\n\n\nis_subtype(subtype, supertype, bound_Generic=None)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWorks like ``issubclass``, but supports PEP 484 style types from typing module.\n\nIf ``subclass`` or ``superclass`` contains unbound ``TypeVar`` s and ``bound_Generic`` is\nprovided, this function attempts to retrieve corresponding values for the\nunbound ``TypeVar`` s from ``bound_Generic``.\n\n\ndeep_type(obj, depth=None, max_sample=None)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTries to construct a type for a given value. In contrast to ``type(...)``, ``deep_type`` does its\nbest to fit structured types from ``typing`` as close as possible to the given value.\nE.g. ``deep_type((1, 2, 'a'))`` will return ``Tuple[int, int, str]`` rather than just ``tuple``.\nSupports various types from ``typing``, but not yet all.\nAlso detects nesting up to given depth (uses ``pytypes.default_typecheck_depth`` if no value is given).\nIf a value for ``max_sample`` is given, this number of elements is probed from lists, sets and dictionaries to determine the element type. By default, all elements are probed. If there are fewer elements than ``max_sample``, all existing elements are probed.\n\n\ntype_str(tp, assumed_globals=None, update_assumed_globals=None, implicit_globals=None, bound_Generic=None)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nGenerates a nicely readable string representation of the given type.\nThe returned representation is workable as a source code string and would reconstruct the given type if handed to eval, provided that globals/locals are configured appropriately (e.g. assumes that various types from ``typing`` have been imported).\nUsed as type-formatting backend of ptypes' code generator abilities in modules ``typelogger`` and ``stubfile_2_converter``.\nIf ``tp`` contains unbound ``TypeVar`` s and ``bound_Generic`` is provided, this function attempts to\nretrieve corresponding values for the unbound ``TypeVar`` s from ``bound_Generic``.\n\n\ndump_cache(path=default_typelogger_path, python2=False, suffix=None)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWrites cached observations by ``@typelogged`` into stubfiles.\n\nFiles will be created in the directory provided as 'path'; overwrites existing files without notice. Uses 'pyi2' suffix if 'python2' flag is given else 'pyi'. Resulting files will be Python 2.7 compliant accordingly.\n\n\nget_Generic_itemtype(sq, simplify=True)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRetrieves the item type from a PEP 484 generic or subclass of such.\n``sq`` must be a ``typing.Tuple`` or (subclass of) ``typing.Iterable`` or ``typing.Container``.\nConsequently this also works with ``typing.List``, ``typing.Set`` and ``typing.Dict``.\nNote that for ``typing.Dict`` and mapping types in general, the key type is regarded as item type.\nFor ``typing.Tuple`` all contained types are returned as a ``typing.Union``.\nIf ``simplify == True`` some effort is taken to eliminate redundancies in such a union.\n\n\nget_Mapping_key_value(mp)\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRetrieves the key and value types from a PEP 484 mapping or subclass of such.\n``mp`` must be a (subclass of) ``typing.Mapping``.\n\n\nget_arg_for_TypeVar(typevar, generic)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRetrieves the parameter value of a given ``TypeVar`` from a ``Generic``.\nReturns ``None`` if the generic does not contain an appropriate value.\nNote that the ``TypeVar`` is compared by instance and not by name.\nE.g. using a local ``TypeVar`` ``T`` would yield different results than\nusing ``typing.T`` despite the equal name.\n\n\nresolve_fw_decl(in_type, module_name=None, globs=None, level=0, search_stack_depth=2)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nResolves forward references in ``in_type``.\n\n``globs`` should be a dictionary containing values for the names\nthat must be resolved in ``in_type``. If ``globs`` is not provided, it\nwill be created by ``__globals__`` from the module named ``module_name``,\nplus ``__locals__`` from the last ``search_stack_depth`` stack frames,\nbeginning at the calling function. This is to resolve cases where ``in_type`` and/or\ntypes it fw-references are defined inside a function.\n\nTo prevent walking the stack, set ``search_stack_depth=0``.\nIdeally provide a proper ``globs`` for best efficiency.\nSee ``util.get_function_perspective_globals`` for obtaining a ``globs`` that can be\ncached. ``util.get_function_perspective_globals`` works like described above.\n\n\nPython 2.7 compliant stubfiles\n------------------------------\n\nCurrently pytypes uses the python runtime, i.e. ``import``, ``eval``, ``dir`` and inspect to parse stubfiles and type comments. A runtime independent parser for stubfiles is a desired future feature, but is not yet available. This means that conventional PEP 484 stubfiles would not work on Python 2.7. To resolve this gap, pytypes features a converter script that can convert conventional stubfiles into Python 2.7 compliant form.\nMore specifically it converts parameter annotations into type comments and converts ``...`` syntax into ``pass``.\n\nAs of this writing it does not yet support stubfiles containing the ``@overload`` decorator. Also, it does not yet convert type annotations of attributes and variables.\n\n\n'pyi2' suffix\n~~~~~~~~~~~~~\n\npytypes uses the suffix 'pyi2' for Python 2.7 compliant stubfiles, but does not require it. Plain 'pyi' is also an acceptable suffix (as far as pytypes is concerned), because Python 2.7 compliant stubfiles can also be used in Python 3.\n\nThe main purpose of 'pyi2' suffix is to avoid name conflicts when conventional stubfiles and Python 2.7 compliant stubfiles coexist for the same module. In that case the pyi2 file will override the pyi file when running on Python 2.7.\n\n\nstubfile\\_2\\_converter\n~~~~~~~~~~~~~~~~~~~~~~\n\nRun stubfile\\_2\\_converter.py to leverage pytypes' stubfile converter capabilities:\n\n``python3 -m pytypes.stubfile_2_converter [options/flags] [in_file]``\n\nUse ``python3 -m pytypes.stubfile_2_converter -h`` to see detailed usage.\n\nBy default the out file will be created in the same folder as the in file, but with 'pyi2' suffix.\n\n\nNext steps\n==========\n\n- support `PEP 526 `__\n- support `overloading `__\n- support named tuple\n- support async-related constructs from typing\n- support notation for `Positional-only arguments `__\n- runtime independent parser for stubfiles\n\n\nContributors\n============\n\npytypes was created in 2016/17 by `Stefan Richthofer `__.\n\nContributors (no specific order, names as provided on github)\n-------------------------------------------------------------\n\n* `Alex Gr\u00f6nholm `__\n* `Mitar `__\n* `Ilya Kulakov `__\n* `Jonas `__\n* `MinJune Kim `__\n\n\nLicense\n=======\n\npytypes is released under Apache 2.0 license.\nA copy is provided in the file LICENSE.\n\n| \n| Copyright 2017, 2018 Stefan Richthofer\n| \n| Licensed under the Apache License, Version 2.0 (the \"License\");\n| you may not use this file except in compliance with the License.\n| You may obtain a copy of the License at\n| \n| `http://www.apache.org/licenses/LICENSE-2.0 `__\n| \n| Unless required by applicable law or agreed to in writing, software\n| distributed under the License is distributed on an \"AS IS\" BASIS,\n| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n| See the License for the specific language governing permissions and\n| limitations under the License.\n\n\nContact\n=======\n\nstefan.richthofer@jyni.org\n\n\n\n",
"description_content_type": "",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/Stewori/pytypes",
"keywords": "",
"license": "Apache-2.0",
"maintainer": "",
"maintainer_email": "",
"name": "pytypes",
"package_url": "https://pypi.org/project/pytypes/",
"platform": "",
"project_url": "https://pypi.org/project/pytypes/",
"project_urls": {
"Homepage": "https://github.com/Stewori/pytypes"
},
"release_url": "https://pypi.org/project/pytypes/1.0b5/",
"requires_dist": [
"typing; python_version == \"2.7\"",
"typing (>=3.5); python_version == \"3.3\"",
"typing (>=3.5); python_version == \"3.4\""
],
"requires_python": "",
"summary": "Typing toolbox for Python 3 _and_ 2.",
"version": "1.0b5"
},
"last_serial": 4043252,
"releases": {
"1.0a1": [],
"1.0b1": [
{
"comment_text": "",
"digests": {
"md5": "b01c036072a4e786b67ab34e9577fd21",
"sha256": "e62965c1939ae9c93ab246ac8900d1578ef24bf7c801244ee7b850c851ff88a7"
},
"downloads": -1,
"filename": "pytypes-1.0b1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "b01c036072a4e786b67ab34e9577fd21",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 75825,
"upload_time": "2017-07-10T19:46:11",
"url": "https://files.pythonhosted.org/packages/dc/64/9a8afebc6de88f667d833fcf78fe026ae64fdb2344f8d6a3bc22580033f1/pytypes-1.0b1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "a1b68354cd87b835001b94663976db10",
"sha256": "970e3fdcd7edb6c40b7f21f433fa9555f930e4bb04c3888da5bd8e9b69b85595"
},
"downloads": -1,
"filename": "pytypes-1.0b1.tar.gz",
"has_sig": false,
"md5_digest": "a1b68354cd87b835001b94663976db10",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 290043,
"upload_time": "2017-07-10T19:46:12",
"url": "https://files.pythonhosted.org/packages/b4/88/09bdb622cd14d3b42e367fd4039123233dcc1aa969584dfc8d9443fc9712/pytypes-1.0b1.tar.gz"
}
],
"1.0b2": [
{
"comment_text": "",
"digests": {
"md5": "f37385b8bca8a691b302eea61767a26c",
"sha256": "3cd5bb963842906dcb55262f006a2cff4446b4e1f7eeca781557ce6488bf5f10"
},
"downloads": -1,
"filename": "pytypes-1.0b2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "f37385b8bca8a691b302eea61767a26c",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 80461,
"upload_time": "2017-11-18T23:58:58",
"url": "https://files.pythonhosted.org/packages/25/47/e522863cb5dc864f68b66a3441e14a05ab45bacf6166f752fa0711caf39c/pytypes-1.0b2-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "3274db53e5d315faf3739ca8cfcb5f9d",
"sha256": "d7f537208b4cf08808b08ce4a85e96019c6eea63c2a0f7924f73da86c1a747c1"
},
"downloads": -1,
"filename": "pytypes-1.0b2.tar.gz",
"has_sig": false,
"md5_digest": "3274db53e5d315faf3739ca8cfcb5f9d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 470767,
"upload_time": "2017-11-18T23:58:59",
"url": "https://files.pythonhosted.org/packages/bc/43/f05f4abffdfdbdff8a5d291a8c7e86513ed3609c92fd2a37a778d4c3a643/pytypes-1.0b2.tar.gz"
}
],
"1.0b3": [
{
"comment_text": "",
"digests": {
"md5": "a8e8707691c69904ae8827833b3628b9",
"sha256": "9631b27588402c4c0f83b4a2b11c52dc0508bff8cb08b32fe7914aab2284b4ec"
},
"downloads": -1,
"filename": "pytypes-1.0b3-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a8e8707691c69904ae8827833b3628b9",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 80461,
"upload_time": "2017-11-19T15:36:49",
"url": "https://files.pythonhosted.org/packages/7e/b9/802333b0f4d7baf0a3f57834dafb637bf0712883a1d6759cde1d72ad042e/pytypes-1.0b3-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "433e47b672f0bfebe6745af29b78a529",
"sha256": "20ae0aa741c63126eb697c41ad576239e397436d9fba93934622d0fd7b20dfd6"
},
"downloads": -1,
"filename": "pytypes-1.0b3.tar.gz",
"has_sig": false,
"md5_digest": "433e47b672f0bfebe6745af29b78a529",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 470733,
"upload_time": "2017-11-19T15:36:50",
"url": "https://files.pythonhosted.org/packages/c3/01/67d4583dba1e2a632354dee43a688bfd432b5ae7cf26b506fffe4c60f151/pytypes-1.0b3.tar.gz"
}
],
"1.0b4": [
{
"comment_text": "",
"digests": {
"md5": "949328d8a4330db738d5b24e6b710375",
"sha256": "5ef3eb11249c9d1cfc77948680257c443cc8f6c2f40c857c2b275ae8cf11c8f9"
},
"downloads": -1,
"filename": "pytypes-1.0b4-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "949328d8a4330db738d5b24e6b710375",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 76920,
"upload_time": "2018-05-15T17:06:45",
"url": "https://files.pythonhosted.org/packages/83/74/2238fa0fbb26b32196907733f933457320cdf90b03eb0e6c6d2769c867a9/pytypes-1.0b4-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "772641334da184975ef48a2d28839199",
"sha256": "a3e661f55da0d037298cf1d7a4e0dde1d4c9f5b7f873c5571fce684e87fc17c9"
},
"downloads": -1,
"filename": "pytypes-1.0b4.tar.gz",
"has_sig": false,
"md5_digest": "772641334da184975ef48a2d28839199",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 305258,
"upload_time": "2018-05-15T17:06:46",
"url": "https://files.pythonhosted.org/packages/d8/e4/3c7a5c89821dd424bc807c1e6257fc3ba349ccfacaa26d3b8f0baaf29936/pytypes-1.0b4.tar.gz"
}
],
"1.0b5": [
{
"comment_text": "",
"digests": {
"md5": "8f30ec66c0fc0d7d4ed3398b1e9b3d9b",
"sha256": "5680ebe14b2e24ed3eb9321b011c773f818198cd8a6c150a7f7bcfa60f1d9127"
},
"downloads": -1,
"filename": "pytypes-1.0b5-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8f30ec66c0fc0d7d4ed3398b1e9b3d9b",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 77483,
"upload_time": "2018-07-09T11:13:01",
"url": "https://files.pythonhosted.org/packages/6f/c7/a6e255959c6e0d878ae01e138952312170fe64bbfa035ba5329ad2eb1eca/pytypes-1.0b5-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "a942733085db175b9f034c1020936c47",
"sha256": "a28f6c7d01c91c9b4a81b4f9523cd0ce620edec3cd30bc389a34540ba3bd9de4"
},
"downloads": -1,
"filename": "pytypes-1.0b5.tar.gz",
"has_sig": false,
"md5_digest": "a942733085db175b9f034c1020936c47",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 306641,
"upload_time": "2018-07-09T11:13:03",
"url": "https://files.pythonhosted.org/packages/ba/f9/6701f7cf163428aecad5bf607741bde295ae2b35bc631c60e668c6cd9c2d/pytypes-1.0b5.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "8f30ec66c0fc0d7d4ed3398b1e9b3d9b",
"sha256": "5680ebe14b2e24ed3eb9321b011c773f818198cd8a6c150a7f7bcfa60f1d9127"
},
"downloads": -1,
"filename": "pytypes-1.0b5-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8f30ec66c0fc0d7d4ed3398b1e9b3d9b",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 77483,
"upload_time": "2018-07-09T11:13:01",
"url": "https://files.pythonhosted.org/packages/6f/c7/a6e255959c6e0d878ae01e138952312170fe64bbfa035ba5329ad2eb1eca/pytypes-1.0b5-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "a942733085db175b9f034c1020936c47",
"sha256": "a28f6c7d01c91c9b4a81b4f9523cd0ce620edec3cd30bc389a34540ba3bd9de4"
},
"downloads": -1,
"filename": "pytypes-1.0b5.tar.gz",
"has_sig": false,
"md5_digest": "a942733085db175b9f034c1020936c47",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 306641,
"upload_time": "2018-07-09T11:13:03",
"url": "https://files.pythonhosted.org/packages/ba/f9/6701f7cf163428aecad5bf607741bde295ae2b35bc631c60e668c6cd9c2d/pytypes-1.0b5.tar.gz"
}
]
}