annot-attrs


Nameannot-attrs JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/centroid457/
Summarywork with annotated but not defined/not used attrs in class
upload_time2024-03-27 07:58:20
maintainerNone
docs_urlNone
authorAndrei Starichenko
requires_python>=3.6
licenseNone
keywords annotations annots not defined attributes attributes
VCS
bugtrack_url
requirements pytest requirements-checker object-info funcs-aux
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # annot_attrs (v0.0.5)

## DESCRIPTION_SHORT
work with annotated but not defined/not used attrs in class

## DESCRIPTION_LONG
Designed to get list of annotated but not defined/not used attrs from class (not instance!).  
    may be helpful further in instance to check that really have values.


## Features
1. get set of unused attributes from class(not instance!)  
2. work with nested classes  
3. get values:  
	- by case insensitive names  
	- by dict key access method  
4. work on any object (over Obj parameter!):  
	- at least for NamedTuple  


********************************************************************************
## License
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).


## Release history
See the [HISTORY.md](HISTORY.md) file for release history.


## Installation
```commandline
pip install annot-attrs
```


## Import
```python
from annot_attrs import *
```


********************************************************************************
## USAGE EXAMPLES
See tests and sourcecode for other examples.

------------------------------
### 1. example1.py
```python
# ===============================================================
### 1. inheritance
# (BEST practice - dont mess classes! use as separated object!)
from annot_attrs import *

class Cls:
    ATTR1: int
    ATTR2: int = 2

obj = Cls(1)

assert AnnotAttrs().annots_get_set(obj) == {"ATTR1", }
assert AnnotAttrs().annots_get_dict(obj) == {"ATTR1": 1, }


# ===============================================================
from annot_attrs import *

class Cls(AnnotAttrs):
    ATTR1: int
    ATTR2: int = 2

assert Cls().annots_get_set() == {"ATTR1", }

class Cls2(Cls):
    ATTR1: int = 2
    ATTR3: int

assert Cls2().annots_get_set() == {"ATTR1", "ATTR3", }

inst = Cls2()
inst.ATTR1 = 1
inst.ATTR2 = 1
inst.ATTR3 = 1

assert Cls2().annots_get_set() == {"ATTR1", "ATTR3", }

assert Cls().ATTR2 == 2
assert Cls().attr2 == 2

assert Cls()["ATTR2"] == 2
assert Cls()["attr2"] == 2

obj = Cls()
try:
    obj.annots_get_dict()
except Exx_AttrNotExist:
    pass
else:
    assert False

obj.ATTR1 = 1
assert obj.annots_get_dict() == {"ATTR1": 1}


# ===============================================================
### 2. Indepandant usage
from annot_attrs import *

try:
    class Cls(AnnotAttrs, NamedTuple):
        ATTR1: int
        ATTR2: int = 2
except TypeError:
    # TypeError: can only inherit from a NamedTuple type and Generic
    pass
else:
    assert True

class Cls(NamedTuple):
    ATTR1: int
    ATTR2: int = 2

obj = Cls(1)
assert AnnotAttrs().annots_get_set(obj) == {"ATTR1", }
assert AnnotAttrs().annots_get_dict(obj) == {"ATTR1": 1}
```

********************************************************************************

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/centroid457/",
    "name": "annot-attrs",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "annotations, annots, not defined attributes, attributes",
    "author": "Andrei Starichenko",
    "author_email": "centroid@mail.ru",
    "download_url": "https://files.pythonhosted.org/packages/7d/d1/7bd9a06a0f700e9c36902b8948a11295dedf5782bb4b1e869435675cd3bf/annot_attrs-0.0.5.tar.gz",
    "platform": null,
    "description": "# annot_attrs (v0.0.5)\r\n\r\n## DESCRIPTION_SHORT\r\nwork with annotated but not defined/not used attrs in class\r\n\r\n## DESCRIPTION_LONG\r\nDesigned to get list of annotated but not defined/not used attrs from class (not instance!).  \r\n    may be helpful further in instance to check that really have values.\r\n\r\n\r\n## Features\r\n1. get set of unused attributes from class(not instance!)  \r\n2. work with nested classes  \r\n3. get values:  \r\n\t- by case insensitive names  \r\n\t- by dict key access method  \r\n4. work on any object (over Obj parameter!):  \r\n\t- at least for NamedTuple  \r\n\r\n\r\n********************************************************************************\r\n## License\r\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\r\n\r\n\r\n## Release history\r\nSee the [HISTORY.md](HISTORY.md) file for release history.\r\n\r\n\r\n## Installation\r\n```commandline\r\npip install annot-attrs\r\n```\r\n\r\n\r\n## Import\r\n```python\r\nfrom annot_attrs import *\r\n```\r\n\r\n\r\n********************************************************************************\r\n## USAGE EXAMPLES\r\nSee tests and sourcecode for other examples.\r\n\r\n------------------------------\r\n### 1. example1.py\r\n```python\r\n# ===============================================================\r\n### 1. inheritance\r\n# (BEST practice - dont mess classes! use as separated object!)\r\nfrom annot_attrs import *\r\n\r\nclass Cls:\r\n    ATTR1: int\r\n    ATTR2: int = 2\r\n\r\nobj = Cls(1)\r\n\r\nassert AnnotAttrs().annots_get_set(obj) == {\"ATTR1\", }\r\nassert AnnotAttrs().annots_get_dict(obj) == {\"ATTR1\": 1, }\r\n\r\n\r\n# ===============================================================\r\nfrom annot_attrs import *\r\n\r\nclass Cls(AnnotAttrs):\r\n    ATTR1: int\r\n    ATTR2: int = 2\r\n\r\nassert Cls().annots_get_set() == {\"ATTR1\", }\r\n\r\nclass Cls2(Cls):\r\n    ATTR1: int = 2\r\n    ATTR3: int\r\n\r\nassert Cls2().annots_get_set() == {\"ATTR1\", \"ATTR3\", }\r\n\r\ninst = Cls2()\r\ninst.ATTR1 = 1\r\ninst.ATTR2 = 1\r\ninst.ATTR3 = 1\r\n\r\nassert Cls2().annots_get_set() == {\"ATTR1\", \"ATTR3\", }\r\n\r\nassert Cls().ATTR2 == 2\r\nassert Cls().attr2 == 2\r\n\r\nassert Cls()[\"ATTR2\"] == 2\r\nassert Cls()[\"attr2\"] == 2\r\n\r\nobj = Cls()\r\ntry:\r\n    obj.annots_get_dict()\r\nexcept Exx_AttrNotExist:\r\n    pass\r\nelse:\r\n    assert False\r\n\r\nobj.ATTR1 = 1\r\nassert obj.annots_get_dict() == {\"ATTR1\": 1}\r\n\r\n\r\n# ===============================================================\r\n### 2. Indepandant usage\r\nfrom annot_attrs import *\r\n\r\ntry:\r\n    class Cls(AnnotAttrs, NamedTuple):\r\n        ATTR1: int\r\n        ATTR2: int = 2\r\nexcept TypeError:\r\n    # TypeError: can only inherit from a NamedTuple type and Generic\r\n    pass\r\nelse:\r\n    assert True\r\n\r\nclass Cls(NamedTuple):\r\n    ATTR1: int\r\n    ATTR2: int = 2\r\n\r\nobj = Cls(1)\r\nassert AnnotAttrs().annots_get_set(obj) == {\"ATTR1\", }\r\nassert AnnotAttrs().annots_get_dict(obj) == {\"ATTR1\": 1}\r\n```\r\n\r\n********************************************************************************\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "work with annotated but not defined/not used attrs in class",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/centroid457/",
        "Source": "https://github.com/centroid457/annot_attrs"
    },
    "split_keywords": [
        "annotations",
        " annots",
        " not defined attributes",
        " attributes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe707c5c2cee444a174bb81cb946d9bad79a07bc4f5481f8654f5abf6151e007",
                "md5": "89d10c49100b5de1068fcc6782cb4016",
                "sha256": "2783a80a65e6480be8b04d3e29204f0b896d515f5defe44266580a8e5ce4e98c"
            },
            "downloads": -1,
            "filename": "annot_attrs-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89d10c49100b5de1068fcc6782cb4016",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4679,
            "upload_time": "2024-03-27T07:58:18",
            "upload_time_iso_8601": "2024-03-27T07:58:18.574380Z",
            "url": "https://files.pythonhosted.org/packages/fe/70/7c5c2cee444a174bb81cb946d9bad79a07bc4f5481f8654f5abf6151e007/annot_attrs-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7dd17bd9a06a0f700e9c36902b8948a11295dedf5782bb4b1e869435675cd3bf",
                "md5": "8b9cfb5170c7a6a07823ab8668f49ee1",
                "sha256": "231d56f58cb60856a8e51d45399e234cde8606856b0cf257c507b26d8da665c8"
            },
            "downloads": -1,
            "filename": "annot_attrs-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "8b9cfb5170c7a6a07823ab8668f49ee1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4653,
            "upload_time": "2024-03-27T07:58:20",
            "upload_time_iso_8601": "2024-03-27T07:58:20.243389Z",
            "url": "https://files.pythonhosted.org/packages/7d/d1/7bd9a06a0f700e9c36902b8948a11295dedf5782bb4b1e869435675cd3bf/annot_attrs-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-27 07:58:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "centroid457",
    "github_project": "annot_attrs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "requirements-checker",
            "specs": []
        },
        {
            "name": "object-info",
            "specs": []
        },
        {
            "name": "funcs-aux",
            "specs": []
        }
    ],
    "lcname": "annot-attrs"
}
        
Elapsed time: 0.21165s