private-attribute-cpp 1.3.4__tar.gz → 1.3.5__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.
- {private_attribute_cpp-1.3.4/private_attribute_cpp.egg-info → private_attribute_cpp-1.3.5}/PKG-INFO +1 -1
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/private_attribute.cpp +20 -24
- private_attribute_cpp-1.3.5/private_attribute.pyi +200 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/setup.py +1 -1
- private_attribute_cpp-1.3.4/private_attribute.pyi +0 -50
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/LICENSE +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/MANIFEST.in +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/README.md +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/picosha2.h +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/private_attribute_cpp.egg-info/top_level.txt +0 -0
- {private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5}/setup.cfg +0 -0
{private_attribute_cpp-1.3.4/private_attribute_cpp.egg-info → private_attribute_cpp-1.3.5}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
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
|
|
@@ -816,11 +816,10 @@ type_delattr(PyObject* typ, std::string attr_name)
|
|
|
816
816
|
// ================================================================
|
|
817
817
|
// _PrivateWrap
|
|
818
818
|
// ================================================================
|
|
819
|
-
typedef struct
|
|
819
|
+
typedef struct {
|
|
820
820
|
PyObject_HEAD
|
|
821
821
|
PyObject *result;
|
|
822
822
|
PyObject *func_list;
|
|
823
|
-
PyObject *decorator;
|
|
824
823
|
} PrivateWrapObject;
|
|
825
824
|
|
|
826
825
|
static PrivateWrapObject* PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list);
|
|
@@ -1009,9 +1008,6 @@ PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list)
|
|
|
1009
1008
|
return NULL;
|
|
1010
1009
|
}
|
|
1011
1010
|
|
|
1012
|
-
self->decorator = decorator;
|
|
1013
|
-
Py_INCREF(decorator);
|
|
1014
|
-
|
|
1015
1011
|
self->func_list = list;
|
|
1016
1012
|
Py_INCREF(list);
|
|
1017
1013
|
|
|
@@ -1025,7 +1021,6 @@ PrivateWrap_dealloc(PrivateWrapObject *self)
|
|
|
1025
1021
|
{
|
|
1026
1022
|
Py_XDECREF(self->result);
|
|
1027
1023
|
Py_XDECREF(self->func_list);
|
|
1028
|
-
Py_XDECREF(self->decorator);
|
|
1029
1024
|
Py_TYPE(self)->tp_free((PyObject *)self);
|
|
1030
1025
|
}
|
|
1031
1026
|
|
|
@@ -2315,8 +2310,7 @@ PrivateAttrType_del(PyObject* cls)
|
|
|
2315
2310
|
(Py_TYPE(cls))->tp_free(cls);
|
|
2316
2311
|
}
|
|
2317
2312
|
|
|
2318
|
-
static const char* PrivateAttrBase_doc = "The class to help to create private attribute. "
|
|
2319
|
-
"It does not have any special behavior, but it can be used as a base class for PrivateAttrType to avoid some conflicts with other metaclasses.";
|
|
2313
|
+
static const char* PrivateAttrBase_doc = "The class to help to create private attribute. It does not have any special behavior.";
|
|
2320
2314
|
|
|
2321
2315
|
// PrivateAttrBase
|
|
2322
2316
|
static PyObject*
|
|
@@ -2378,7 +2372,7 @@ PrivateTempObject_name(PyObject* self, void* /*closure*/)
|
|
|
2378
2372
|
{
|
|
2379
2373
|
PyObject* name = ((PrivateTempObject*)self)->tmp->name;
|
|
2380
2374
|
if (!name) {
|
|
2381
|
-
PyErr_SetString(PyExc_RuntimeError, "object not init");
|
|
2375
|
+
PyErr_SetString(PyExc_RuntimeError, "object not init or have been used");
|
|
2382
2376
|
return nullptr;
|
|
2383
2377
|
}
|
|
2384
2378
|
Py_INCREF(name);
|
|
@@ -2390,7 +2384,7 @@ PrivateTempObject_base(PyObject* self, void* /*closure*/)
|
|
|
2390
2384
|
{
|
|
2391
2385
|
PyObject* base = ((PrivateTempObject*)self)->tmp->bases;
|
|
2392
2386
|
if (!base) {
|
|
2393
|
-
PyErr_SetString(PyExc_RuntimeError, "object not init");
|
|
2387
|
+
PyErr_SetString(PyExc_RuntimeError, "object not init or have been used");
|
|
2394
2388
|
return nullptr;
|
|
2395
2389
|
}
|
|
2396
2390
|
Py_INCREF(base);
|
|
@@ -2402,7 +2396,7 @@ PrivateTempObject_attrs(PyObject* self, void* /*closure*/)
|
|
|
2402
2396
|
{
|
|
2403
2397
|
PyObject* attrs = ((PrivateTempObject*)self)->tmp->attrs_copy;
|
|
2404
2398
|
if (!attrs) {
|
|
2405
|
-
PyErr_SetString(PyExc_RuntimeError, "object not init");
|
|
2399
|
+
PyErr_SetString(PyExc_RuntimeError, "object not init or have been used");
|
|
2406
2400
|
return nullptr;
|
|
2407
2401
|
}
|
|
2408
2402
|
Py_INCREF(attrs);
|
|
@@ -2414,7 +2408,7 @@ PrivateTempObject_kwds(PyObject* self, void* /*closure*/)
|
|
|
2414
2408
|
{
|
|
2415
2409
|
PyObject* kwds = ((PrivateTempObject*)self)->tmp->base_kwds;
|
|
2416
2410
|
if (!kwds) {
|
|
2417
|
-
PyErr_SetString(PyExc_RuntimeError, "object not init");
|
|
2411
|
+
PyErr_SetString(PyExc_RuntimeError, "object not init or have been used");
|
|
2418
2412
|
return nullptr;
|
|
2419
2413
|
}
|
|
2420
2414
|
Py_INCREF(kwds);
|
|
@@ -2473,15 +2467,19 @@ static PyTypeObject PrivateTempType = {
|
|
|
2473
2467
|
static PyObject*
|
|
2474
2468
|
prepare_for_PrivateAttr(PyObject* /*self*/, PyObject* args, PyObject* kwargs)
|
|
2475
2469
|
{
|
|
2476
|
-
|
|
2477
|
-
if (!
|
|
2470
|
+
PrivateAttrCreationData* tmp_data = new PrivateAttrCreationData();
|
|
2471
|
+
if (!PrivateAttrType_preprocess(args, kwargs, *tmp_data)) {
|
|
2472
|
+
tmp_data->clear();
|
|
2473
|
+
delete tmp_data;
|
|
2478
2474
|
return NULL;
|
|
2479
2475
|
}
|
|
2480
|
-
tmp
|
|
2481
|
-
if (!
|
|
2482
|
-
|
|
2476
|
+
PrivateTempObject* tmp = PyObject_New(PrivateTempObject, &PrivateTempType);
|
|
2477
|
+
if (!tmp) {
|
|
2478
|
+
tmp_data->clear();
|
|
2479
|
+
delete tmp_data;
|
|
2483
2480
|
return NULL;
|
|
2484
2481
|
}
|
|
2482
|
+
tmp->tmp = tmp_data;
|
|
2485
2483
|
return (PyObject*)tmp;
|
|
2486
2484
|
}
|
|
2487
2485
|
|
|
@@ -2542,7 +2540,6 @@ register_metaclass(PyObject* /*self*/, PyObject* metaclass)
|
|
|
2542
2540
|
((PyTypeObject*)metaclass)->tp_getattro = PrivateAttrType_getattr;
|
|
2543
2541
|
((PyTypeObject*)metaclass)->tp_setattro = PrivateAttrType_setattr;
|
|
2544
2542
|
((PyTypeObject*)metaclass)->tp_finalize = register_finalize;
|
|
2545
|
-
((PyTypeObject*)metaclass)->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
|
|
2546
2543
|
Py_RETURN_NONE;
|
|
2547
2544
|
}
|
|
2548
2545
|
|
|
@@ -2655,13 +2652,14 @@ static PyGetSetDef PrivateModule_getsetters[] = {
|
|
|
2655
2652
|
static const char* prepare_and_postprocess_doc = R"(function for custom metaclass to create private attributes class.
|
|
2656
2653
|
|
|
2657
2654
|
def prepare(name: str, bases: tuple, attrs: dict, **kwds) -> tempobject:
|
|
2658
|
-
the function to prepare for creating private attributes class. It will return a temporary object which has the same information as the arguments.
|
|
2655
|
+
the function to prepare for creating private attributes class. It will return a temporary object which has the same information as the arguments.
|
|
2659
2656
|
|
|
2660
2657
|
def postprocess(type: type, tmp: tempobject) -> None:
|
|
2661
2658
|
the function to postprocess for creating private attributes class. The custom metaclass can call this
|
|
2662
2659
|
|
|
2663
2660
|
def register_metaclass(metaclass: type) -> None:
|
|
2664
|
-
the function to register custom metaclass. The custom metaclass must call this function to register itself before creating any private attributes class,
|
|
2661
|
+
the function to register custom metaclass. The custom metaclass must call this function to register itself before creating any private attributes class,
|
|
2662
|
+
otherwise the private attributes class created by this custom metaclass will not work.
|
|
2665
2663
|
|
|
2666
2664
|
All usage of this module should be like:
|
|
2667
2665
|
```
|
|
@@ -2675,18 +2673,16 @@ class PrivateAbcMeta(ABCMeta):
|
|
|
2675
2673
|
private_attribute.postprocess(typ, temp)
|
|
2676
2674
|
return typ
|
|
2677
2675
|
|
|
2678
|
-
|
|
2679
2676
|
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
2680
2677
|
```
|
|
2681
2678
|
)";
|
|
2682
2679
|
|
|
2683
2680
|
static const char* ensure_type_doc = R"(function for custom metaclass to ensure the type is a private attributes class.
|
|
2684
|
-
|
|
2685
2681
|
def ensure_type(type: type) -> None:
|
|
2686
2682
|
the function to ensure the type is a private attributes class `tp_getattro`, `tp_setattro` and `tp_finalizer`.
|
|
2687
2683
|
)";
|
|
2688
2684
|
|
|
2689
|
-
static const char* ensure_metaclass_doc = R"(function for custom metaclass to ensure the metaclass is
|
|
2685
|
+
static const char* ensure_metaclass_doc = R"(function for custom metaclass to ensure the metaclass is working.
|
|
2690
2686
|
def ensure_metaclass(metaclass: type) -> None:
|
|
2691
2687
|
the function to ensure the metaclass `tp_getattro`, `tp_setattro` and `tp_finalizer`.
|
|
2692
2688
|
)";
|
|
@@ -2740,7 +2736,7 @@ A module that provides a metaclass for creating classes with private attributes.
|
|
|
2740
2736
|
Private attributes are defined in the `__private_attrs__` sequence and are only
|
|
2741
2737
|
You can use the `PrivateAttrBase` metaclass to create classes with private attributes.
|
|
2742
2738
|
The attributes which are private are not on the instance's `__dict__` and cannot be accessed outside
|
|
2743
|
-
but in the
|
|
2739
|
+
but in the methods defined in class it is reachable.
|
|
2744
2740
|
Usage example:
|
|
2745
2741
|
```python
|
|
2746
2742
|
class MyClass(PrivateAttrBase):
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"""A module that provides a metaclass for creating classes with private attributes.
|
|
2
|
+
Private attributes are defined in the `__private_attrs__` sequence and are only
|
|
3
|
+
You can use the `PrivateAttrBase` metaclass to create classes with private attributes.
|
|
4
|
+
The attributes which are private are not on the instance's `__dict__` and cannot be accessed outside
|
|
5
|
+
but in the methods defined in class it is reachable.
|
|
6
|
+
Usage example:
|
|
7
|
+
```python
|
|
8
|
+
class MyClass(PrivateAttrBase):
|
|
9
|
+
__private_attrs__ = ('_private_attr1',)
|
|
10
|
+
def __init__(self):
|
|
11
|
+
self._private_attr1 = 1
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def public_attr1(self):
|
|
15
|
+
return self._private_attr1
|
|
16
|
+
```
|
|
17
|
+
"""
|
|
18
|
+
from typing import Any, TypeVar, Callable, TypedDict, Sequence, Generic
|
|
19
|
+
from types import FunctionType
|
|
20
|
+
|
|
21
|
+
# define the dict that must have a key "__private_attrs__" and value must be the sequence of strings
|
|
22
|
+
class PrivateAttrDict(TypedDict):
|
|
23
|
+
__private_attrs__: Sequence[str]
|
|
24
|
+
|
|
25
|
+
T = TypeVar('T')
|
|
26
|
+
|
|
27
|
+
class _PrivateWrap(Generic[T]):
|
|
28
|
+
@property
|
|
29
|
+
def result(self) -> T:
|
|
30
|
+
"the final result of decorating"
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def funcs(self) -> tuple[FunctionType]:
|
|
35
|
+
"the original functions"
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
def __getattr__(self, name: str) -> Any:
|
|
39
|
+
return getattr(self.result, name)
|
|
40
|
+
|
|
41
|
+
TVar = TypeVar('TVar')
|
|
42
|
+
|
|
43
|
+
class PrivateWrapProxy:
|
|
44
|
+
"""
|
|
45
|
+
PrivateWrapProxy is a proxy for private attributes.
|
|
46
|
+
Usage:
|
|
47
|
+
```
|
|
48
|
+
from private_attribute import PrivateWrapProxy, PrivateAttrBase
|
|
49
|
+
|
|
50
|
+
class MyClass(PrivateAttrBase):
|
|
51
|
+
__private_attrs__ = ()
|
|
52
|
+
@PrivateWrapProxy(decorator)
|
|
53
|
+
def my_method(self): ...
|
|
54
|
+
|
|
55
|
+
@PrivateWrapProxy(decorator)
|
|
56
|
+
def my_method2(self): ...
|
|
57
|
+
```
|
|
58
|
+
It returned a '_PrivateWrap' object.
|
|
59
|
+
|
|
60
|
+
If you need to decorate more function, use like this:
|
|
61
|
+
```
|
|
62
|
+
from private_attribute import PrivateWrapProxy, PrivateAttrBase
|
|
63
|
+
|
|
64
|
+
class MyClass(PrivateAttrBase):
|
|
65
|
+
__private_attrs__ = ()
|
|
66
|
+
@PrivateWrapProxy(decorator)
|
|
67
|
+
def my_method(self): ...
|
|
68
|
+
|
|
69
|
+
@PrivateWrapProxy(my_method.some_decorator, my_method)
|
|
70
|
+
def my_method(self): ...
|
|
71
|
+
```
|
|
72
|
+
"""
|
|
73
|
+
def __init__(self, decorator: Callable[[TVar], T], orig: _PrivateWrap[Any]|None = None, /) -> None: ...
|
|
74
|
+
def __call__(self, func: TVar, /) -> _PrivateWrap[T]: ...
|
|
75
|
+
|
|
76
|
+
class PrivateAttrType(type):
|
|
77
|
+
"metaclass for private attributes"
|
|
78
|
+
def __new__(cls, name: str, bases: tuple,
|
|
79
|
+
attrs: PrivateAttrDict, /,
|
|
80
|
+
private_func: Callable[[int, str], str]|None = None) -> PrivateAttrType: ...
|
|
81
|
+
|
|
82
|
+
class PrivateAttrBase(metaclass=PrivateAttrType):
|
|
83
|
+
"The class to help to create private attribute. It does not have any special behavior."
|
|
84
|
+
__slots__ = ()
|
|
85
|
+
__private_attrs__ = ()
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class _PrivateTemp:
|
|
89
|
+
@property
|
|
90
|
+
def name(self) -> str: ...
|
|
91
|
+
@property
|
|
92
|
+
def bases(self) -> tuple[type]: ...
|
|
93
|
+
@property
|
|
94
|
+
def attrs(self) -> dict[str, Any]: ...
|
|
95
|
+
@property
|
|
96
|
+
def kwds(self) -> dict[str, Any]: ...
|
|
97
|
+
|
|
98
|
+
def prepare(name: str, bases: tuple, attrs: PrivateAttrDict, /, **kwds) -> _PrivateTemp:
|
|
99
|
+
"""
|
|
100
|
+
function for custom metaclass to create private attributes class.
|
|
101
|
+
|
|
102
|
+
def prepare(name: str, bases: tuple, attrs: dict, **kwds) -> tempobject:
|
|
103
|
+
the function to prepare for creating private attributes class. It will return a temporary object which has the same information as the arguments.
|
|
104
|
+
|
|
105
|
+
def postprocess(type: type, tmp: tempobject) -> None:
|
|
106
|
+
the function to postprocess for creating private attributes class. The custom metaclass can call this
|
|
107
|
+
|
|
108
|
+
def register_metaclass(metaclass: type) -> None:
|
|
109
|
+
the function to register custom metaclass. The custom metaclass must call this function to register itself before creating any private attributes class,
|
|
110
|
+
otherwise the private attributes class created by this custom metaclass will not work.
|
|
111
|
+
|
|
112
|
+
All usage of this module should be like:
|
|
113
|
+
```
|
|
114
|
+
from abc import ABCMeta
|
|
115
|
+
import private_attribute
|
|
116
|
+
|
|
117
|
+
class PrivateAbcMeta(ABCMeta):
|
|
118
|
+
def __new__(cls, *args, **kwargs):
|
|
119
|
+
temp = private_attribute.prepare(*args, **kwargs)
|
|
120
|
+
typ = super().__new__(cls, temp.name, temp.bases, temp.attrs, **temp.kwds)
|
|
121
|
+
private_attribute.postprocess(typ, temp)
|
|
122
|
+
return typ
|
|
123
|
+
|
|
124
|
+
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
125
|
+
```
|
|
126
|
+
"""
|
|
127
|
+
...
|
|
128
|
+
|
|
129
|
+
def postprocess(typ: type, temp: _PrivateTemp, /) -> None:
|
|
130
|
+
"""
|
|
131
|
+
function for custom metaclass to create private attributes class.
|
|
132
|
+
|
|
133
|
+
def prepare(name: str, bases: tuple, attrs: dict, **kwds) -> tempobject:
|
|
134
|
+
the function to prepare for creating private attributes class. It will return a temporary object which has the same information as the arguments.
|
|
135
|
+
|
|
136
|
+
def postprocess(type: type, tmp: tempobject) -> None:
|
|
137
|
+
the function to postprocess for creating private attributes class. The custom metaclass can call this
|
|
138
|
+
|
|
139
|
+
def register_metaclass(metaclass: type) -> None:
|
|
140
|
+
the function to register custom metaclass. The custom metaclass must call this function to register itself before creating any private attributes class,
|
|
141
|
+
otherwise the private attributes class created by this custom metaclass will not work.
|
|
142
|
+
|
|
143
|
+
All usage of this module should be like:
|
|
144
|
+
```
|
|
145
|
+
from abc import ABCMeta
|
|
146
|
+
import private_attribute
|
|
147
|
+
|
|
148
|
+
class PrivateAbcMeta(ABCMeta):
|
|
149
|
+
def __new__(cls, *args, **kwargs):
|
|
150
|
+
temp = private_attribute.prepare(*args, **kwargs)
|
|
151
|
+
typ = super().__new__(cls, temp.name, temp.bases, temp.attrs, **temp.kwds)
|
|
152
|
+
private_attribute.postprocess(typ, temp)
|
|
153
|
+
return typ
|
|
154
|
+
|
|
155
|
+
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
156
|
+
```
|
|
157
|
+
"""
|
|
158
|
+
...
|
|
159
|
+
def register_metaclass(typ: type, /) -> None:
|
|
160
|
+
"""
|
|
161
|
+
function for custom metaclass to create private attributes class.
|
|
162
|
+
|
|
163
|
+
def prepare(name: str, bases: tuple, attrs: dict, **kwds) -> tempobject:
|
|
164
|
+
the function to prepare for creating private attributes class. It will return a temporary object which has the same information as the arguments.
|
|
165
|
+
|
|
166
|
+
def postprocess(type: type, tmp: tempobject) -> None:
|
|
167
|
+
the function to postprocess for creating private attributes class. The custom metaclass can call this
|
|
168
|
+
|
|
169
|
+
def register_metaclass(metaclass: type) -> None:
|
|
170
|
+
the function to register custom metaclass. The custom metaclass must call this function to register itself before creating any private attributes class,
|
|
171
|
+
otherwise the private attributes class created by this custom metaclass will not work.
|
|
172
|
+
|
|
173
|
+
All usage of this module should be like:
|
|
174
|
+
```
|
|
175
|
+
from abc import ABCMeta
|
|
176
|
+
import private_attribute
|
|
177
|
+
|
|
178
|
+
class PrivateAbcMeta(ABCMeta):
|
|
179
|
+
def __new__(cls, *args, **kwargs):
|
|
180
|
+
temp = private_attribute.prepare(*args, **kwargs)
|
|
181
|
+
typ = super().__new__(cls, temp.name, temp.bases, temp.attrs, **temp.kwds)
|
|
182
|
+
private_attribute.postprocess(typ, temp)
|
|
183
|
+
return typ
|
|
184
|
+
|
|
185
|
+
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
186
|
+
```
|
|
187
|
+
"""
|
|
188
|
+
...
|
|
189
|
+
def ensure_type(typ: type, /) -> None:
|
|
190
|
+
"""function for custom metaclass to ensure the type is a private attributes class.
|
|
191
|
+
def ensure_type(type: type) -> None:
|
|
192
|
+
the function to ensure the type is a private attributes class `tp_getattro`, `tp_setattro` and `tp_finalizer`.
|
|
193
|
+
"""
|
|
194
|
+
...
|
|
195
|
+
def ensure_metaclass(typ: type, /) -> None:
|
|
196
|
+
"""function for custom metaclass to ensure the metaclass is working.
|
|
197
|
+
def ensure_metaclass(metaclass: type) -> None:
|
|
198
|
+
the function to ensure the metaclass `tp_getattro`, `tp_setattro` and `tp_finalizer`.
|
|
199
|
+
"""
|
|
200
|
+
...
|
{private_attribute_cpp-1.3.4 → private_attribute_cpp-1.3.5/private_attribute_cpp.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
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
|
|
@@ -19,7 +19,7 @@ readme = open('README.md').read()
|
|
|
19
19
|
|
|
20
20
|
setup(
|
|
21
21
|
name='private_attribute_cpp',
|
|
22
|
-
version='1.3.
|
|
22
|
+
version='1.3.5',
|
|
23
23
|
author="HuangHaoHua",
|
|
24
24
|
author_email="13140752715@example.com",
|
|
25
25
|
description='A Python package that provides a way to define private attributes in C++ implementation.',
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
from typing import Any, TypeVar, Callable, TypedDict, Sequence, Generic
|
|
2
|
-
from types import FunctionType
|
|
3
|
-
|
|
4
|
-
# define the dict that must have a key "__private_attrs__" and value must be the sequence of strings
|
|
5
|
-
class PrivateAttrDict(TypedDict):
|
|
6
|
-
__private_attrs__: Sequence[str]
|
|
7
|
-
|
|
8
|
-
T = TypeVar('T')
|
|
9
|
-
|
|
10
|
-
class _PrivateWrap(Generic[T]):
|
|
11
|
-
@property
|
|
12
|
-
def result(self) -> T: ...
|
|
13
|
-
|
|
14
|
-
@property
|
|
15
|
-
def funcs(self) -> tuple[FunctionType]: ...
|
|
16
|
-
|
|
17
|
-
def __getattr__(self, name: str) -> Any:
|
|
18
|
-
return getattr(self.result, name)
|
|
19
|
-
|
|
20
|
-
TVar = TypeVar('TVar')
|
|
21
|
-
|
|
22
|
-
class PrivateWrapProxy:
|
|
23
|
-
def __init__(self, decorator: Callable[[TVar], T], orig: _PrivateWrap[Any]|None = None, /) -> None: ...
|
|
24
|
-
def __call__(self, func: TVar, /) -> _PrivateWrap[T]: ...
|
|
25
|
-
|
|
26
|
-
class PrivateAttrType(type):
|
|
27
|
-
def __new__(cls, name: str, bases: tuple,
|
|
28
|
-
attrs: PrivateAttrDict, /,
|
|
29
|
-
private_func: Callable[[int, str], str]|None = None) -> PrivateAttrType: ...
|
|
30
|
-
|
|
31
|
-
class PrivateAttrBase(metaclass=PrivateAttrType):
|
|
32
|
-
__slots__ = ()
|
|
33
|
-
__private_attrs__ = ()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class _PrivateTemp:
|
|
37
|
-
@property
|
|
38
|
-
def name(self) -> str: ...
|
|
39
|
-
@property
|
|
40
|
-
def bases(self) -> tuple[type]: ...
|
|
41
|
-
@property
|
|
42
|
-
def attrs(self) -> dict[str, Any]: ...
|
|
43
|
-
@property
|
|
44
|
-
def kwds(self) -> dict[str, Any]: ...
|
|
45
|
-
|
|
46
|
-
def prepare(name: str, bases: tuple, attrs: PrivateAttrDict, /, **kwds) -> _PrivateTemp: ...
|
|
47
|
-
def postprocess(typ: type, temp: _PrivateTemp, /) -> None: ...
|
|
48
|
-
def register_metaclass(typ: type, /) -> None: ...
|
|
49
|
-
def ensure_type(typ: type, /) -> None: ...
|
|
50
|
-
def ensure_metaclass(typ: type, /) -> None: ...
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|