private-attribute-cpp 2.1.8__tar.gz → 2.1.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {private_attribute_cpp-2.1.8/private_attribute_cpp.egg-info → private_attribute_cpp-2.1.9}/PKG-INFO +1 -1
  2. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/private_attribute.pyi +15 -4
  3. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
  4. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/setup.py +1 -1
  5. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/LICENSE +0 -0
  6. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/MANIFEST.in +0 -0
  7. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/README.md +0 -0
  8. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/picosha2.h +0 -0
  9. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/private_attribute.cpp +0 -0
  10. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
  11. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
  12. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
  13. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/private_attribute_cpp.egg-info/top_level.txt +0 -0
  14. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/setup.cfg +0 -0
  15. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_attr_classify_owner.py +0 -0
  16. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_class_private_attrs.py +0 -0
  17. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_gc_collect.py +0 -0
  18. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_private_abc.py +0 -0
  19. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_private_attrs.py +0 -0
  20. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_private_func.py +0 -0
  21. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_private_inheritance.py +0 -0
  22. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_private_method.py +0 -0
  23. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_private_wrap.py +0 -0
  24. {private_attribute_cpp-2.1.8 → private_attribute_cpp-2.1.9}/tests/test_slots_cycle.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: private_attribute_cpp
3
- Version: 2.1.8
3
+ Version: 2.1.9
4
4
  Summary: A Python package that provides a way to define private attributes in C++ implementation.
5
5
  Home-page: https://github.com/Locked-chess-official/private_attribute_cpp
6
6
  Author: HuangHaoHua
@@ -15,14 +15,14 @@ class MyClass(PrivateAttrBase):
15
15
  return self._private_attr1
16
16
  ```
17
17
  """
18
- from typing import Any, TypeVar, Callable, TypedDict, Sequence, Generic, Optional
18
+ from typing import Any, TypeVar, Callable, TypedDict, Sequence, Generic, Optional, cast
19
19
  from types import FunctionType
20
20
 
21
21
  # define the dict that must have a key "__private_attrs__" and value must be the sequence of strings
22
22
  class _PrivateAttrDict(TypedDict):
23
23
  __private_attrs__: Optional[Sequence[str]]
24
24
 
25
- _T = TypeVar('T')
25
+ _T = TypeVar('_T')
26
26
 
27
27
  class _PrivateWrap(Generic[_T]):
28
28
  @property
@@ -38,9 +38,20 @@ class _PrivateWrap(Generic[_T]):
38
38
  def __getattr__(self, name: str) -> Any:
39
39
  return getattr(self.result, name)
40
40
 
41
- _TVar = TypeVar('TVar')
41
+ def __call__(self, *args: Any, **kwargs: Any) -> Any:
42
+ if callable(self.result):
43
+ return self.result(*args, **kwargs)
44
+ raise TypeError(f'{self.result!r} is not callable')
42
45
 
43
- class PrivateWrapProxy:
46
+ def __get__(self, instance: Any, owner: type) -> Any:
47
+ if hasattr(self.result, "__get__"):
48
+ descriptor = cast(Any, self.result)
49
+ return descriptor.__get__(instance, owner)
50
+ return self.result
51
+
52
+ _TVar = TypeVar('_TVar')
53
+
54
+ class PrivateWrapProxy(Generic[_TVar, _T]):
44
55
  """
45
56
  PrivateWrapProxy is a proxy for private attributes.
46
57
  Usage:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: private_attribute_cpp
3
- Version: 2.1.8
3
+ Version: 2.1.9
4
4
  Summary: A Python package that provides a way to define private attributes in C++ implementation.
5
5
  Home-page: https://github.com/Locked-chess-official/private_attribute_cpp
6
6
  Author: HuangHaoHua
@@ -24,7 +24,7 @@ readme = open('README.md').read()
24
24
 
25
25
  setup(
26
26
  name='private_attribute_cpp',
27
- version='2.1.8',
27
+ version='2.1.9',
28
28
  author="HuangHaoHua",
29
29
  author_email="13140752715@example.com",
30
30
  description='A Python package that provides a way to define private attributes in C++ implementation.',