no-global-nonlocal-vars


Nameno-global-nonlocal-vars JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/tylerlum/no_global_nonlocal_vars
SummaryFunction decorator that ensures that no global and no nonlocal variables are used, making Jupyter notebooks much safer
upload_time2023-10-07 23:50:02
maintainer
docs_urlNone
authorTyler Lum
requires_python
license
keywords python jupyter notebook decorator global nonlocal
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # no_global_nonlocal_vars

Function decorator that ensures that no global and no nonlocal variables are used, making Jupyter notebooks much safer

# Installing

Install:
```
pip install no_global_nonlocal_vars
```

# Usage

```
# Correct Output
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_GOOD(x, repeat):
    return np.array([x] * repeat)


# Error from typo
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_typo_GOOD(x_typo, repeat_typo):
    return np.array([x] * repeat)


# Nested function works
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_nested_GOOD(x, repeat=10):

    @no_global_nonlocal_vars
    def helper(x, repeat):
        return np.array([x] * repeat)

    return helper(x, repeat)


# Error from nonlocal variable typo
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_nested_typo_GOOD(x, repeat=10):

    @no_global_nonlocal_vars
    def helper(x_typo, repeat_typo):
        return np.array([x] * repeat)

    return helper(x, repeat)
```

# Notes

* The errors show up only upon first time running the function, not at function definition time

# Related Work

* https://github.com/tillahoffmann/localscope

* https://github.com/diazona/localscope

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tylerlum/no_global_nonlocal_vars",
    "name": "no-global-nonlocal-vars",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,jupyter,notebook,decorator,global,nonlocal",
    "author": "Tyler Lum",
    "author_email": "tylergwlum@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/60/cc/73df33e1e1bfe9ee2fdf2cf327e9755507da74771039197b2a0f256d195d/no_global_nonlocal_vars-0.0.2.tar.gz",
    "platform": null,
    "description": "# no_global_nonlocal_vars\n\nFunction decorator that ensures that no global and no nonlocal variables are used, making Jupyter notebooks much safer\n\n# Installing\n\nInstall:\n```\npip install no_global_nonlocal_vars\n```\n\n# Usage\n\n```\n# Correct Output\n@no_global_nonlocal_vars\ndef test_no_global_nonlocal_vars_GOOD(x, repeat):\n    return np.array([x] * repeat)\n\n\n# Error from typo\n@no_global_nonlocal_vars\ndef test_no_global_nonlocal_vars_typo_GOOD(x_typo, repeat_typo):\n    return np.array([x] * repeat)\n\n\n# Nested function works\n@no_global_nonlocal_vars\ndef test_no_global_nonlocal_vars_nested_GOOD(x, repeat=10):\n\n    @no_global_nonlocal_vars\n    def helper(x, repeat):\n        return np.array([x] * repeat)\n\n    return helper(x, repeat)\n\n\n# Error from nonlocal variable typo\n@no_global_nonlocal_vars\ndef test_no_global_nonlocal_vars_nested_typo_GOOD(x, repeat=10):\n\n    @no_global_nonlocal_vars\n    def helper(x_typo, repeat_typo):\n        return np.array([x] * repeat)\n\n    return helper(x, repeat)\n```\n\n# Notes\n\n* The errors show up only upon first time running the function, not at function definition time\n\n# Related Work\n\n* https://github.com/tillahoffmann/localscope\n\n* https://github.com/diazona/localscope\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Function decorator that ensures that no global and no nonlocal variables are used, making Jupyter notebooks much safer",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/tylerlum/no_global_nonlocal_vars"
    },
    "split_keywords": [
        "python",
        "jupyter",
        "notebook",
        "decorator",
        "global",
        "nonlocal"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee2331e328abd80f000144626c7bd52aa4f5f805b823d7c92ee74798d63ec981",
                "md5": "e9020558273baf825474b7192e6c1856",
                "sha256": "d3789dafe87d095f95d5585e3fe846b0fee4961bc8e9245b52817799ac249b5e"
            },
            "downloads": -1,
            "filename": "no_global_nonlocal_vars-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e9020558273baf825474b7192e6c1856",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3513,
            "upload_time": "2023-10-07T23:50:00",
            "upload_time_iso_8601": "2023-10-07T23:50:00.316453Z",
            "url": "https://files.pythonhosted.org/packages/ee/23/31e328abd80f000144626c7bd52aa4f5f805b823d7c92ee74798d63ec981/no_global_nonlocal_vars-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "60cc73df33e1e1bfe9ee2fdf2cf327e9755507da74771039197b2a0f256d195d",
                "md5": "3b736dce7f7087cefa0b1e4c984b9a42",
                "sha256": "c2858700bfcb25f1e0eb1cd8e0b6ad9d49b6698529ce19e28df9388db0844eaa"
            },
            "downloads": -1,
            "filename": "no_global_nonlocal_vars-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "3b736dce7f7087cefa0b1e4c984b9a42",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3242,
            "upload_time": "2023-10-07T23:50:02",
            "upload_time_iso_8601": "2023-10-07T23:50:02.774532Z",
            "url": "https://files.pythonhosted.org/packages/60/cc/73df33e1e1bfe9ee2fdf2cf327e9755507da74771039197b2a0f256d195d/no_global_nonlocal_vars-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-07 23:50:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tylerlum",
    "github_project": "no_global_nonlocal_vars",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "no-global-nonlocal-vars"
}
        
Elapsed time: 0.37804s