{ "info": { "author": "Ramon Hagenaars", "author_email": "ramon.hagenaars@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "[![image](https://img.shields.io/pypi/pyversions/typish.svg)](https://pypi.org/project/typish/)\n[![Build Status](https://travis-ci.org/ramonhagenaars/typish.svg?branch=master)](https://travis-ci.org/ramonhagenaars/typish)\n[![Pypi version](https://badge.fury.io/py/typish.svg)](https://badge.fury.io/py/typish)\n[![codecov](https://codecov.io/gh/ramonhagenaars/typish/branch/master/graph/badge.svg)](https://codecov.io/gh/ramonhagenaars/typish)\n\n# Typish\n\n* Functions for thorough checks on types\n* Instance checks considering generics\n* Typesafe Duck-typing\n\n## Installation\n\n```\npip install typish\n```\n\n## Content\n\n### Functions\n\n| Function | Description\n|---|---\n| ``subclass_of(cls: type, *args: type) -> bool`` | Returns whether ``cls`` is a sub type of *all* types in ``args``\n| ``instance_of(obj: object, *args: type) -> bool`` | Returns whether ``cls`` is an instance of *all* types in ``args``\n| ``get_origin`` | Return the \"origin\" of a generic type. E.g. ``get_origin(List[str])`` gives ``list``.\n| ``get_args`` | Return the arguments of a generic type. E.g. ``get_args(List[str])`` gives ``(str, )``.\n| ``get_alias`` | Return the ``typing`` alias for a type. E.g ``get_alias(list)`` gives ``List``.\n| ``get_type`` | Return the (generic) type of an instance. E.g. a list of ints will give ``List[int]``.\n| ``common_ancestor`` | Return the closest common ancestor of the given instances.\n| ``common_ancestor_of_types`` | Return the closest common ancestor of the given classes.\n\n### Types\n\n| Type | Description\n|---|---|\n| ``T`` | A generic Type var.\n| ``KT`` | A Type var for keys in a dict.\n| ``VT`` | A type var for values in a dict.\n| ``Empty`` | The type of emptiness (= ``Parameter.empty``).\n| ``Unknown`` | The type of something unknown.\n| ``Module`` | The type of a module.\n| ``NoneType`` | The type of ``None``.\n\n### SubscriptableType\nThis metaclass allows a type to become subscriptable.\n\n*Example:*\n```python\nclass MyClass(metaclass=SubscriptableType):\n ...\n```\nNow you can do:\n```python\nMyClass2 = MyClass['some args']\nprint(MyClass2.__args__)\nprint(MyClass2.__origin__)\n```\nOutput:\n```\nsome args\n\n```\n\n### Something\nDefine an interface with ``typish.Something``.\n\n*Example:*\n```python\nDuck = Something['walk': Callable[[], None], \n 'quack': Callable[[], None]]\n```\n\nAnything that has the attributes defined in ``Something`` with the right type is \nconsidered an instance of that ``Something`` (classes, objects, even modules...).\n\nThe builtin ``isinstance`` is supported as well as ``typish.instance_of``.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ramonhagenaars/typish", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "typish", "package_url": "https://pypi.org/project/typish/", "platform": "", "project_url": "https://pypi.org/project/typish/", "project_urls": { "Homepage": "https://github.com/ramonhagenaars/typish" }, "release_url": "https://pypi.org/project/typish/1.2.0/", "requires_dist": null, "requires_python": "", "summary": "Functionality for types", "version": "1.2.0" }, "last_serial": 5816467, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "bbd6326f2341ec5a1a7698a845f5d660", "sha256": "bc4b57537444735286c119f60485611762e367bebfb9ca7621425ce2aecbdbd8" }, "downloads": -1, "filename": "typish-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "bbd6326f2341ec5a1a7698a845f5d660", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7376, "upload_time": "2019-08-03T15:59:45", "url": "https://files.pythonhosted.org/packages/93/aa/38e5149bfcc7b2921d86866659fb7b61f4f824c0957278f398dfff5314ee/typish-1.0.0-py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "ee4c84d0356abd25ed9f4ebe7c52af9b", "sha256": "c39f43589dcfefcb383e6a90cc8a03ddde29cbd9f2992e68c3112c2258499098" }, "downloads": -1, "filename": "typish-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ee4c84d0356abd25ed9f4ebe7c52af9b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8188, "upload_time": "2019-08-06T20:09:40", "url": "https://files.pythonhosted.org/packages/37/46/cbae8e600d1ec595fc0489b2934c6ee2a37a972383900f7e7e413aaa5644/typish-1.1.0-py3-none-any.whl" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "058d6811053f89f7164f36ce7b104188", "sha256": "101c79de50561b552886dbfaf0d1ea4d8efccdf6cabc98dfccdec98b33e44e77" }, "downloads": -1, "filename": "typish-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "058d6811053f89f7164f36ce7b104188", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8976, "upload_time": "2019-09-11T19:14:23", "url": "https://files.pythonhosted.org/packages/70/c7/dfbf7953820a6644a261d9aa05114affb4c146a008330fe4fbd8f1a627c4/typish-1.2.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "058d6811053f89f7164f36ce7b104188", "sha256": "101c79de50561b552886dbfaf0d1ea4d8efccdf6cabc98dfccdec98b33e44e77" }, "downloads": -1, "filename": "typish-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "058d6811053f89f7164f36ce7b104188", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8976, "upload_time": "2019-09-11T19:14:23", "url": "https://files.pythonhosted.org/packages/70/c7/dfbf7953820a6644a261d9aa05114affb4c146a008330fe4fbd8f1a627c4/typish-1.2.0-py3-none-any.whl" } ] }