work with annotated but not defined/not used attrs in class
Project description
annot_attrs
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
- get set of unused attributes from class(not instance!)
- work with nested classes
- get values
- by case insensitive names
- by dict key access method
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install annot-attrs
Import
from annot_attrs import *
GUIDE
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}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
annot_attrs-0.0.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for annot_attrs-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ec16059eaaf23dd0756b8e3fedc5188945dfff2851f7ab1b0e68db3c17bb0f2 |
|
MD5 | 11693b05e52b7cd82b25a0bd5d64659b |
|
BLAKE2b-256 | 5ad54fee67c7b45f49d51366f3684f31e1ed4db6c70cb27ec12aaea1de07e1a1 |