{ "info": { "author": "Brandt Bucher", "author_email": "brandtbucher@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "
\n\n
\n\n

Flython

\n\n[![latest version](https://img.shields.io/github/release-pre/brandtbucher/flython.svg?style=for-the-badge&label=latest)![latest release date](https://img.shields.io/github/release-date-pre/brandtbucher/flython.svg?style=for-the-badge&label=released)](https://github.com/brandtbucher/flython/releases)[![build status](https://img.shields.io/travis/com/brandtbucher/flython/master.svg?style=for-the-badge)](https://travis-ci.com/brandtbucher/flython)[![issues](https://img.shields.io/github/issues-raw/brandtbucher/flython.svg?label=issues&style=for-the-badge)](https://github.com/brandtbucher/flython/issues)\n\n
\n\n---\n\n**Flython is still in an unstable development phase. Many features do not work perfectly (if at all), and interfaces are still being tweaked and played with. Bug reports, questions, feedback, fixes, and other contributions on [GitHub](https://github.com/brandtbucher/flython) are _greatly_ appreciated \u2013 just open an [issue](https://github.com/brandtbucher/flython/issues/new) or [pull request](https://github.com/brandtbucher/flython/compare)!**\n\n---\n\nAbout\n-----\n\nPython is an _incredibly_ dynamic language. While this is one of its greatest strengths, it also tends to create difficulties for engineers who wish to program in a strictly functional paradigm. Flython provides tools that statically analyze compiled CPython bytecode for near-perfect protection against statefulness, side-effects, mutation, and other sources of functional breakdown.\n\nFlython's design is inspired by (and modeled after) [mypy](https://github.com/python/mypy). If you've ever used similar static analysis tools, integrating Flython into your workflow will feel familiar and natural.\n\nExamples\n--------\n\nThe easiest way to install Flython is with `pip`:\n\n```\n$ pip install flython\n```\n\nWhen your code is functionally pure, Flython stays invisible:\n\n```\n$ flython pure.py\n```\n\nWhen it's not, Flython warns you. Consider the following module, `impure.py`:\n\n```py\ndef modify_object(target):\n \"\"\"Mutate target.\"\"\"\n\n target.foo = \"bar\"\n del target.baz\n\n\ndef modify_object_sneaky(target):\n \"\"\"Mutate target in a hard-to-catch way.\"\"\"\n\n setter, deleter = setattr, delattr\n\n setter(target, \"foo\", \"bar\")\n deleter(target, \"baz\")\n\n\n# Create some mutable objects:\nmy_list = [*range(3)]\nmy_set = {i for i in range(3, 6)}\nmy_dict = dict(((\"six\", 6), (\"seven\", 7), (\"eight\", 8)))\n\n# Mutate those objects:\nmy_list[0] = \"zero\"\nmy_set -= my_set\ndel my_dict[\"eight\"]\n```\n\nWhen we run Flython, it catches quite a bit of the impurity:\n\n```\n$ flython impure.py\nAttempt to store value 'bar' to variable attribute target.foo. (impure.py, line 4)\nAttempt to delete variable attribute target.baz. (impure.py, line 5)\nAttempt to store value 'zero' to contained item my_list[0]. (impure.py, line 23)\nAttempt to modify variable. Use normal assignment (my_set = my_set - my_set) instead of augmented assignment (my_set -= my_set). (impure.py, line 24)\nAttempt to delete contained item my_dict['eight']. (impure.py, line 25)\n```\n\nUsing `--strict`, though, catches _all_ of its issues:\n\n```\n$ flython impure.py --strict\nAttempt to store value 'bar' to variable attribute target.foo. (impure.py, line 4)\nAttempt to delete variable attribute target.baz. (impure.py, line 5)\nAttempt to load dynamic function 'setattr'. (impure.py, line 11)\nAttempt to load dynamic function 'delattr'. (impure.py, line 11)\nAttempt to use mutable built-in type 'list'. (impure.py, line 18)\nAttempt to use mutable built-in type 'set'. (impure.py, line 19)\nAttempt to use mutable built-in type 'dict'. (impure.py, line 20)\nAttempt to store value 'zero' to contained item my_list[0]. (impure.py, line 23)\nAttempt to modify variable. Use normal assignment (my_set = my_set - my_set) instead of augmented assignment (my_set -= my_set). (impure.py, line 24)\nAttempt to delete contained item my_dict['eight']. (impure.py, line 25)\n```\n\nFeatures\n--------\n\n### Command-Line Tool\n\n```sh\n$ flython MODULE [ MODULE ... ]\n```\n\nExecute the `flython` package directly with a list of modules to statically analyze them. It accepts some basic options:\n\n```\n$ flython --help\n\nStatic functional purity analysis for Python.\n\nOptions:\n\n --no-dynamic Don't allow \"breakpoint\" (Python 3.7+), \"delattr\", \"eval\", \"exec\", \"globals\", \"locals\", or \"setattr\".\n --no-io Don't allow \"input\", \"open\", or \"print\".\n --no-mutables Don't allow mutable built-in types.\n --no-raise Don't allow \"raise\" statements.\n --skip-imports Don't check imports.\n --strict Same as --no-dynamic --no-io --no-mutables --no-raise.\n ```\n\n### Flython Comments\n\n```py\n... # flython: ignore\n```\n\nIndicate that Flython should silence any errors occurring on this line.\n\nNote that this does not silence followed imports. Users should skip imports with `# flython: skip` if they do not wish for them to be analyzed.\n\n```py\n... # flython: skip\n```\n\nIndicate that Flython shouldn't check any new code objects defined on this line. This includes imports, class definitions, function definitions, generator expressions, or `list`/`dict`/`set` comprehensions.\n\n### Programmatic Interface\n\n```\nflython.main(*modules: str, **options: bool) -> Generator[Union[OSError, SyntaxError], None, None]\n```\n\nThe `main` function takes any number of string filepaths and yields `Exception` objects identical to those reported by the command-line interface.\n\nRequirements\n------------\n\nFlython officially supports CPython 3.4+ on Linux. It also attempts to maintain compatibility with PyPy 3.5 and all development versions of CPython 3.5+ (including unstable branches). It has no external dependencies.\n\nPython 3.6+ is recommended for Flython development work, along with the latest versions of the packages in `requirements.txt`.\n\nContributing\n------------\n\nContributions are welcome! See `CONTRIBUTING.md` for more info.\n\n
\n\n
\n\n

The MIT License

\n\n

Copyright \u00a9 2018 Gary Brandt Bucher, II.

\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n
\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/brandtbucher/flython", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "flython", "package_url": "https://pypi.org/project/flython/", "platform": "", "project_url": "https://pypi.org/project/flython/", "project_urls": { "Homepage": "https://github.com/brandtbucher/flython" }, "release_url": "https://pypi.org/project/flython/0.2.0/", "requires_dist": [ "typing ; python_version < \"3.5\"" ], "requires_python": "", "summary": "Static functional purity analysis for Python.", "version": "0.2.0" }, "last_serial": 4605152, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "6d133c495a4e265b5fd2205b2c901e91", "sha256": "55168a36c37ee961a9cc3fa0f87963a4eb5359c968eeba0a191f4697cb9f04c6" }, "downloads": -1, "filename": "flython-0.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6d133c495a4e265b5fd2205b2c901e91", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10917, "upload_time": "2018-12-11T17:10:37", "url": "https://files.pythonhosted.org/packages/ec/8e/54c15382f2fe39d7220d552150f324628d9485021a960b4f80f628f03dba/flython-0.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "288b04b0c30a052a7a6201c5c0d6c8cd", "sha256": "dce17f407ac2b4cb937b4993cafa4869a6f769f68a6e898af575b13164d5c0e3" }, "downloads": -1, "filename": "flython-0.0.0.tar.gz", "has_sig": false, "md5_digest": "288b04b0c30a052a7a6201c5c0d6c8cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10932, "upload_time": "2018-12-11T17:10:39", "url": "https://files.pythonhosted.org/packages/7c/da/b9c5e980a5378b3e58a47a074a288167125b86f3e3caffebdf32de25f0c3/flython-0.0.0.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "673e80c4263fd2d3719cab524d7e8592", "sha256": "d9895e3fbca897ecc67d66b5ca34104ff992266b5cf8993010f8e7616cf241e0" }, "downloads": -1, "filename": "flython-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "673e80c4263fd2d3719cab524d7e8592", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10934, "upload_time": "2018-12-15T20:07:22", "url": "https://files.pythonhosted.org/packages/74/bb/201f841c8cee0ab0f00799d691fab3bfddfa4b1c219fe4dd11f9cd14ebfa/flython-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4036efeae77fa9769ef71c3018e200af", "sha256": "454b2e15aa03155fa1679756c149aeb2eda0753582e979bc5a99160e9dacb181" }, "downloads": -1, "filename": "flython-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4036efeae77fa9769ef71c3018e200af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10989, "upload_time": "2018-12-15T20:07:25", "url": "https://files.pythonhosted.org/packages/80/1b/1a1d6f430c3a25945dd8bb3fa9f648c38bfdb8384cca35840f6c64bee7f6/flython-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4239c659795565a2898b305fca880ebc", "sha256": "b6020153c59bef660629e5a8279505448718e35f2daf5477833b6009e3ed3126" }, "downloads": -1, "filename": "flython-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4239c659795565a2898b305fca880ebc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10930, "upload_time": "2018-12-15T22:41:20", "url": "https://files.pythonhosted.org/packages/7b/5b/5b0b650cc362a95365a842bd8eb7fad3f18dfb9678ffc28c1f686a784a4d/flython-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "17da299a393bd63a2a44505cac2d33bb", "sha256": "ed7356f81947c8779e85bdc05c2f79ed660c95fbeb4433fd617eca61e72e474e" }, "downloads": -1, "filename": "flython-0.1.1.tar.gz", "has_sig": false, "md5_digest": "17da299a393bd63a2a44505cac2d33bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10987, "upload_time": "2018-12-15T22:41:22", "url": "https://files.pythonhosted.org/packages/fa/e8/0cf20bf34d209dfff1c7e8d4efe14c9a6d9959bf451a96138e049214b923/flython-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "7c9a328d87af5389d698d7d8669a086f", "sha256": "698c2b2321a3df4cd4c848434b3475743bcf9c6a0393a151d8cc22b5424cd49d" }, "downloads": -1, "filename": "flython-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7c9a328d87af5389d698d7d8669a086f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10736, "upload_time": "2018-12-16T17:42:19", "url": "https://files.pythonhosted.org/packages/3c/01/80a8bf8019b502ce9fd2424e46c4d55a1e913caad198d5f4f5a461d04da4/flython-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "246acd80bde0833239d803aa640e9551", "sha256": "4850230177ac69e602681a53f76d3a0b7604ee048c1528f3960dbe5a7963a99e" }, "downloads": -1, "filename": "flython-0.2.0.tar.gz", "has_sig": false, "md5_digest": "246acd80bde0833239d803aa640e9551", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10833, "upload_time": "2018-12-16T17:42:21", "url": "https://files.pythonhosted.org/packages/57/f6/a4d15000be3d629dffb216122576b1e0fd32eb518c62d372a6549ac9ea19/flython-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7c9a328d87af5389d698d7d8669a086f", "sha256": "698c2b2321a3df4cd4c848434b3475743bcf9c6a0393a151d8cc22b5424cd49d" }, "downloads": -1, "filename": "flython-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7c9a328d87af5389d698d7d8669a086f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10736, "upload_time": "2018-12-16T17:42:19", "url": "https://files.pythonhosted.org/packages/3c/01/80a8bf8019b502ce9fd2424e46c4d55a1e913caad198d5f4f5a461d04da4/flython-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "246acd80bde0833239d803aa640e9551", "sha256": "4850230177ac69e602681a53f76d3a0b7604ee048c1528f3960dbe5a7963a99e" }, "downloads": -1, "filename": "flython-0.2.0.tar.gz", "has_sig": false, "md5_digest": "246acd80bde0833239d803aa640e9551", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10833, "upload_time": "2018-12-16T17:42:21", "url": "https://files.pythonhosted.org/packages/57/f6/a4d15000be3d629dffb216122576b1e0fd32eb518c62d372a6549ac9ea19/flython-0.2.0.tar.gz" } ] }