enforce-with


Nameenforce-with JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryEnforce the usage of with keyword
upload_time2025-10-06 19:38:31
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords enforce with
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:
```python
@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

```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "enforce-with",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "enforce, with",
    "author": null,
    "author_email": "pyhacks <enginyildirim111@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8b/0d/899ef47a9dc8a532f2d5daf8f8e3d2ac29390d287c5c62169fa09455a1ff/enforce_with-1.1.0.tar.gz",
    "platform": null,
    "description": "# enforce-with\nThis library makes it possible to enforce the usage of ```with``` keyword\n\n# Installation\n```pip install enforce-with```\n\n# Usage\n@enforce_with.**enforce_with**\n\nDecorate 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:\n```python\n@enforce_with.enforce_with\nclass MyClass:\n    def __init__(self):\n        self.var = 10\n\n    def func(self):\n        pass\n\n    def __enter__(self):\n        print(\"entering\")\n        return self\n\n    def __exit__(self, exc_type, exc_value, traceback):\n        print(\"exiting\")\n\nwith MyClass() as obj:\n    obj.var # Ok\n    obj.func() # Ok\n\nMyClass().var # Error\nMyClass().func() # Error\n\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Enforce the usage of with keyword",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/pyhacks/enforce-with"
    },
    "split_keywords": [
        "enforce",
        " with"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "69d5b657338fcfc35b68191edeb05055ee0678d367afa2b47c5a1b8c6f574577",
                "md5": "63aed425c074add97ab3a4c2c955c326",
                "sha256": "80ecc5d58d4fb5e92daed42c4d3ccff9a060cd630a6a682f357bc8d59c4f4be5"
            },
            "downloads": -1,
            "filename": "enforce_with-1.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "63aed425c074add97ab3a4c2c955c326",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 2065,
            "upload_time": "2025-10-06T19:38:30",
            "upload_time_iso_8601": "2025-10-06T19:38:30.004685Z",
            "url": "https://files.pythonhosted.org/packages/69/d5/b657338fcfc35b68191edeb05055ee0678d367afa2b47c5a1b8c6f574577/enforce_with-1.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8b0d899ef47a9dc8a532f2d5daf8f8e3d2ac29390d287c5c62169fa09455a1ff",
                "md5": "9a47e9e8711aca588c0e747d474dd485",
                "sha256": "5810777dc9d56aca503bb9391dcfe47a9a32274348f82747452deaf90f15ca3a"
            },
            "downloads": -1,
            "filename": "enforce_with-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9a47e9e8711aca588c0e747d474dd485",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 1358,
            "upload_time": "2025-10-06T19:38:31",
            "upload_time_iso_8601": "2025-10-06T19:38:31.202998Z",
            "url": "https://files.pythonhosted.org/packages/8b/0d/899ef47a9dc8a532f2d5daf8f8e3d2ac29390d287c5c62169fa09455a1ff/enforce_with-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-06 19:38:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pyhacks",
    "github_project": "enforce-with",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "enforce-with"
}
        
Elapsed time: 1.53373s