Skip to main content

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

Metadata

Release files for no-global-nonlocal-vars 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for no-global-nonlocal-vars 0.0.2
File Size Uploaded Provenance
no_global_nonlocal_vars-0.0.2.tar.gz 3.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for no-global-nonlocal-vars 0.0.2
File Interpreter ABI Platform
no_global_nonlocal_vars-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / no_global_nonlocal_vars-0.0.2.tar.gz

Download URL no_global_nonlocal_vars-0.0.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c2858700bfcb25f1e0eb1cd8e0b6ad9d49b6698529ce19e28df9388db0844eaa
BLAKE2b-256 checksum
How to use checksums
60cc73df33e1e1bfe9ee2fdf2cf327e9755507da74771039197b2a0f256d195d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release files / no_global_nonlocal_vars-0.0.2-py3-none-any.whl

Download URL no_global_nonlocal_vars-0.0.2-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3789dafe87d095f95d5585e3fe846b0fee4961bc8e9245b52817799ac249b5e
BLAKE2b-256 checksum
How to use checksums
ee2331e328abd80f000144626c7bd52aa4f5f805b823d7c92ee74798d63ec981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Security for no-global-nonlocal-vars 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page