Metadata-Version: 2.1
Name: no-global-nonlocal-vars
Version: 0.0.1
Summary: Function decorator that ensures that no global and no nonlocal variables are used, making Jupyter notebooks much safer
Home-page: UNKNOWN
Author: Tyler Lum
Author-email: tylergwlum@gmail.com
License: UNKNOWN
Keywords: python,jupyter,notebook,decorator,global,nonlocal
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Topic :: Utilities
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
License-File: LICENSE

# 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


