Skip to main content

enforce-with

This library makes it possible to enforce the usage of with keyword

Installation

pip install enforce-with

Usage

@enforce_with.enforce_with

Decorate your class with this decorator and it will no longer be possible to access the members of its instances unless you access them inside a with block. Example:

@enforce_with.enforce_with
class MyClass:
    def __init__(self):
        self.var = 10

    def func(self):
        pass

    def __enter__(self):
        print("entering")
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        print("exiting")

with MyClass() as obj:
    obj.var # Ok
    obj.func() # Ok

MyClass().var # Error
MyClass().func() # Error

Metadata

Release files for enforce-with 1.1.0

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

Source distribution (sdist)

Source distribution for enforce-with 1.1.0
File Size Uploaded Provenance Actions
enforce_with-1.1.0.tar.gz 1.4 kB Without provenance Details for enforce_with-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for enforce-with 1.1.0
File Interpreter ABI Platform Actions
enforce_with-1.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for enforce_with-1.1.0-py2.py3-none-any.whl

Total release size: 3.4 kB

Release files / enforce_with-1.1.0.tar.gz

Download URL enforce_with-1.1.0.tar.gz
Size 1.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5810777dc9d56aca503bb9391dcfe47a9a32274348f82747452deaf90f15ca3a
BLAKE2b-256 checksum
How to use checksums
8b0d899ef47a9dc8a532f2d5daf8f8e3d2ac29390d287c5c62169fa09455a1ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / enforce_with-1.1.0-py2.py3-none-any.whl

Download URL enforce_with-1.1.0-py2.py3-none-any.whl
Size 2.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
80ecc5d58d4fb5e92daed42c4d3ccff9a060cd630a6a682f357bc8d59c4f4be5
BLAKE2b-256 checksum
How to use checksums
69d5b657338fcfc35b68191edeb05055ee0678d367afa2b47c5a1b8c6f574577
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Security for enforce-with 1.1.0

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

1.1.0 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