{ "info": { "author": "Devin Fee", "author_email": "devin@devinfee.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": ".. image:: https://raw.githubusercontent.com/dfee/forge/master/docs/_static/forge-horizontal.png\n :alt: forge logo\n\n==================================================\n``forge`` *(python) signatures for fun and profit*\n==================================================\n\n\n.. image:: https://img.shields.io/badge/pypi-v2018.6.0-blue.svg\n :target: https://pypi.org/project/python-forge/\n :alt: pypi project\n.. image:: https://img.shields.io/badge/license-MIT-blue.svg\n :target: https://pypi.org/project/python-forge/\n :alt: MIT license\n.. image:: https://img.shields.io/badge/python-3.5%2C%203.6%2C%203.7-blue.svg\n :target: https://pypi.org/project/python-forge/\n :alt: Python 3.5+\n.. image:: https://travis-ci.org/dfee/forge.png?branch=master\n :target: https://travis-ci.org/dfee/forge\n :alt: master Travis CI Status\n.. image:: https://coveralls.io/repos/github/dfee/forge/badge.svg?branch=master\n :target: https://coveralls.io/github/dfee/forge?branch=master\n :alt: master Coveralls Status\n.. image:: https://readthedocs.org/projects/python-forge/badge/\n :target: http://python-forge.readthedocs.io/en/latest/\n :alt: Documentation Status\n\n.. overview-start\n\n``forge`` is an elegant Python package for revising function signatures at runtime.\nThis libraries aim is to help you write better, more literate code with less boilerplate.\n\n.. overview-end\n\n\n.. installation-start\n\nInstallation\n============\n\n``forge`` is a Python-only package `hosted on PyPI `_ for **Python 3.5+**.\n\nThe recommended installation method is `pip-installing `_ into a `virtualenv `_:\n\n.. code-block:: console\n\n $ pip install python-forge\n\n.. installation-end\n\n\n\nExample\n=======\n\n.. example-start\n\nConsider a library like `requests `_ that provides a useful API for performing HTTP requests.\nEvery HTTP method has it's own function which is a thin wrapper around ``requests.Session.request``.\nThe code is a little more than 150 lines, with about 90% of that being boilerplate.\nUsing ``forge`` we can get that back down to about 10% it's current size, while *increasing* the literacy of the code.\n\n.. code-block:: python\n\n import forge\n import requests\n\n request = forge.copy(requests.Session.request, exclude='self')(requests.request)\n\n def with_method(method):\n revised = forge.modify(\n 'method', default=method, bound=True,\n kind=forge.FParameter.POSITIONAL_ONLY,\n )(request)\n revised.__name__ = method.lower()\n return revised\n\n post = with_method('POST')\n get = with_method('GET')\n put = with_method('PUT')\n delete = with_method('DELETE')\n options = with_method('OPTIONS')\n head = with_method('HEAD')\n patch = with_method('PATCH')\n\nSo what happened?\nThe first thing we did was create an alternate ``request`` function to replace ``requests.request`` that provides the exact same functionality but makes its parameters explicit:\n\n.. code-block:: python\n\n # requests.get() looks like this:\n assert forge.repr_callable(requests.get) == 'get(url, params=None, **kwargs)'\n\n # our get() calls the same code, but looks like this:\n assert forge.repr_callable(get) == (\n 'get(url, params=None, data=None, headers=None, cookies=None, '\n 'files=None, auth=None, timeout=None, allow_redirects=True, '\n 'proxies=None, hooks=None, stream=None, verify=None, cert=None, '\n 'json=None'\n ')'\n )\n\nNext, we built a factory function ``with_method`` that creates new functions which make HTTP requests with the proper HTTP verb.\nBecause the ``method`` parameter is bound, it won't show up it is removed from the resulting functions signature.\nOf course, the signature of these generated functions remains explicit, let's try it out:\n\n.. code-block:: python\n\n response = get('http://google.com')\n assert 'Feeling Lucky' in response.text\n\nYou can review the alternate code (the actual implementation) by visiting the code for `requests.api `_.\n\n.. example-end\n\n\n.. project-information-start\n\nProject information\n===================\n\n``forge`` is released under the `MIT `_ license,\nits documentation lives at `Read the Docs `_,\nthe code on `GitHub `_,\nand the latest release on `PyPI `_.\nIt\u2019s rigorously tested on Python 3.6+ and PyPy 3.5+.\n\n``forge`` is authored by `Devin Fee `_.\nOther contributors are listed under https://github.com/dfee/forge/graphs/contributors.\n\n.. project-information-end\n\n\n.. _requests_api_get: https://github.com/requests/requests/blob/991e8b76b7a9d21f698b24fa0058d3d5968721bc/requests/api.py#L61\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/dfee/forge", "keywords": "signatures,parameters,arguments", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-forge", "package_url": "https://pypi.org/project/python-forge/", "platform": "", "project_url": "https://pypi.org/project/python-forge/", "project_urls": { "Homepage": "http://github.com/dfee/forge" }, "release_url": "https://pypi.org/project/python-forge/18.6.0/", "requires_dist": [ "coverage; extra == 'dev'", "mypy; extra == 'dev'", "pylint; extra == 'dev'", "pytest; extra == 'dev'", "sphinx; extra == 'dev'", "sphinx-autodoc-typehints; extra == 'dev'", "sphinx-paramlinks; extra == 'dev'", "sphinx (>=1.7.4); extra == 'docs'", "docutils; extra == 'docs'", "requests; extra == 'docs'", "sphinx-paramlinks; extra == 'docs'", "coverage; extra == 'testing'", "mypy; extra == 'testing'", "pylint; extra == 'testing'", "pytest; extra == 'testing'" ], "requires_python": "", "summary": "forge (python signatures)", "version": "18.6.0" }, "last_serial": 3957386, "releases": { "18.5.0": [ { "comment_text": "", "digests": { "md5": "7c9880bd3a7caa4b81613cef6ae2e45f", "sha256": "7797d67143be3ebaa12f07d87854b8bd2742a5655d57d0bb7e4af2fb58a1a3aa" }, "downloads": -1, "filename": "python_forge-18.5.0-0-py35-none-any.whl", "has_sig": false, "md5_digest": "7c9880bd3a7caa4b81613cef6ae2e45f", "packagetype": "bdist_wheel", "python_version": "py35", "requires_python": null, "size": 20777, "upload_time": "2018-05-25T02:42:41", "url": "https://files.pythonhosted.org/packages/81/91/bd64e36a1cb66a6543beecb57063e8d3a49c46dd59162a2b80c4382e429e/python_forge-18.5.0-0-py35-none-any.whl" } ], "18.6.0": [ { "comment_text": "", "digests": { "md5": "1ce4f6e6f128f37179095928f713155a", "sha256": "bf91f9a42150d569c2e9a0d90ab60a8cbed378bdf185e5120532a3481067395c" }, "downloads": -1, "filename": "python_forge-18.6.0-py35-none-any.whl", "has_sig": false, "md5_digest": "1ce4f6e6f128f37179095928f713155a", "packagetype": "bdist_wheel", "python_version": "py35", "requires_python": null, "size": 31294, "upload_time": "2018-06-13T11:41:06", "url": "https://files.pythonhosted.org/packages/41/d6/e9af8e22d153ebbf584833c1c96d590046f522ae2a86978d4efe496b4aac/python_forge-18.6.0-py35-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1ce4f6e6f128f37179095928f713155a", "sha256": "bf91f9a42150d569c2e9a0d90ab60a8cbed378bdf185e5120532a3481067395c" }, "downloads": -1, "filename": "python_forge-18.6.0-py35-none-any.whl", "has_sig": false, "md5_digest": "1ce4f6e6f128f37179095928f713155a", "packagetype": "bdist_wheel", "python_version": "py35", "requires_python": null, "size": 31294, "upload_time": "2018-06-13T11:41:06", "url": "https://files.pythonhosted.org/packages/41/d6/e9af8e22d153ebbf584833c1c96d590046f522ae2a86978d4efe496b4aac/python_forge-18.6.0-py35-none-any.whl" } ] }