python-dictattr
Advanced tools
+25
-6
@@ -7,3 +7,3 @@ #!/usr/bin/env python3 | ||
| __author__ = "ChenyangGao <https://chenyanggao.github.io>" | ||
| __version__ = (0, 0, 2) | ||
| __version__ = (0, 0, 3) | ||
| __all__ = [ | ||
@@ -29,3 +29,9 @@ "odict", "AttrDict", "MapAttr", "MuMapAttr", | ||
| def __hash__(self, /) -> int: # type: ignore | ||
| return id(self) | ||
| def __eq__(self, value, /) -> bool: | ||
| return self is value or super().__eq__(value) | ||
| class AttrDict(dict[K, V]): | ||
@@ -37,10 +43,15 @@ | ||
| def __hash__(self, /) -> int: # type: ignore | ||
| return id(self) | ||
| def __eq__(self, value, /) -> bool: | ||
| return self is value or super().__eq__(value) | ||
| @Mapping.register | ||
| class MapAttr(Generic[K, V]): | ||
| def __init__(self, d: None | dict = None, /): | ||
| def __init__(self, /, *args, **kwds): | ||
| self.__dict__: dict[K, V] # type: ignore | ||
| if d is not None: | ||
| self.__dict__ = d | ||
| self.__dict__.update(*args, **kwds) | ||
@@ -67,4 +78,12 @@ def __contains__(self, key, /) -> bool: | ||
| @classmethod | ||
| def of(cls, /, *args, **kwds) -> Self: | ||
| return cls(dict(*args, **kwds)) | ||
| def of( | ||
| cls, | ||
| d: None | dict[K, V] = None, | ||
| /, | ||
| ) -> Self: | ||
| if d is None: | ||
| return cls() | ||
| self = __class__.__new__(cls) # type: ignore | ||
| self.__dict__ = d | ||
| return self | ||
@@ -71,0 +90,0 @@ |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: python-dictattr | ||
| Version: 0.0.2 | ||
| Version: 0.0.3 | ||
| Summary: Python dictattr. | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-dictattr |
+1
-1
| [tool.poetry] | ||
| name = "python-dictattr" | ||
| version = "0.0.2" | ||
| version = "0.0.3" | ||
| description = "Python dictattr." | ||
@@ -5,0 +5,0 @@ authors = ["ChenyangGao <wosiwujm@gmail.com>"] |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
7914
6.34%121
14.15%