omlish 0.0.0.dev23__py3-none-any.whl → 0.0.0.dev25__py3-none-any.whl
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.
- omlish/__about__.py +16 -4
- omlish/_manifests.json +1 -0
- omlish/bootstrap/diag.py +2 -2
- omlish/check.py +202 -24
- omlish/collections/__init__.py +2 -2
- omlish/collections/utils.py +3 -3
- omlish/concurrent/threadlets.py +5 -0
- omlish/dataclasses/__init__.py +1 -0
- omlish/dataclasses/impl/LICENSE +279 -0
- omlish/dataclasses/impl/init.py +10 -2
- omlish/dataclasses/impl/metadata.py +3 -3
- omlish/dataclasses/impl/reflect.py +1 -1
- omlish/dataclasses/utils.py +16 -3
- omlish/diag/pycharm.py +69 -10
- omlish/docker.py +16 -11
- omlish/genmachine.py +2 -1
- omlish/graphs/trees.py +1 -1
- omlish/lang/__init__.py +14 -1
- omlish/lang/cached.py +5 -2
- omlish/lang/descriptors.py +33 -16
- omlish/lang/resources.py +60 -0
- omlish/lang/typing.py +32 -0
- omlish/lite/logs.py +133 -4
- omlish/logs/__init__.py +17 -2
- omlish/logs/configs.py +13 -1
- omlish/logs/formatters.py +0 -1
- omlish/marshal/__init__.py +2 -0
- omlish/marshal/helpers.py +27 -0
- omlish/specs/jsonschema/keywords/base.py +2 -2
- omlish/specs/jsonschema/keywords/parse.py +1 -1
- omlish/specs/jsonschema/schemas/draft202012/metaschema.json +58 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/applicator.json +48 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/content.json +17 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/core.json +51 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/format-annotation.json +14 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/format-assertion.json +14 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/format.json +14 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/meta-data.json +37 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/unevaluated.json +15 -0
- omlish/specs/jsonschema/schemas/draft202012/vocabularies/validation.json +98 -0
- omlish/stats.py +1 -0
- {omlish-0.0.0.dev23.dist-info → omlish-0.0.0.dev25.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev23.dist-info → omlish-0.0.0.dev25.dist-info}/RECORD +46 -33
- {omlish-0.0.0.dev23.dist-info → omlish-0.0.0.dev25.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev23.dist-info → omlish-0.0.0.dev25.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev23.dist-info → omlish-0.0.0.dev25.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,279 @@
|
|
1
|
+
A. HISTORY OF THE SOFTWARE
|
2
|
+
==========================
|
3
|
+
|
4
|
+
Python was created in the early 1990s by Guido van Rossum at Stichting
|
5
|
+
Mathematisch Centrum (CWI, see https://www.cwi.nl) in the Netherlands
|
6
|
+
as a successor of a language called ABC. Guido remains Python's
|
7
|
+
principal author, although it includes many contributions from others.
|
8
|
+
|
9
|
+
In 1995, Guido continued his work on Python at the Corporation for
|
10
|
+
National Research Initiatives (CNRI, see https://www.cnri.reston.va.us)
|
11
|
+
in Reston, Virginia where he released several versions of the
|
12
|
+
software.
|
13
|
+
|
14
|
+
In May 2000, Guido and the Python core development team moved to
|
15
|
+
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
|
16
|
+
year, the PythonLabs team moved to Digital Creations, which became
|
17
|
+
Zope Corporation. In 2001, the Python Software Foundation (PSF, see
|
18
|
+
https://www.python.org/psf/) was formed, a non-profit organization
|
19
|
+
created specifically to own Python-related Intellectual Property.
|
20
|
+
Zope Corporation was a sponsoring member of the PSF.
|
21
|
+
|
22
|
+
All Python releases are Open Source (see https://opensource.org for
|
23
|
+
the Open Source Definition). Historically, most, but not all, Python
|
24
|
+
releases have also been GPL-compatible; the table below summarizes
|
25
|
+
the various releases.
|
26
|
+
|
27
|
+
Release Derived Year Owner GPL-
|
28
|
+
from compatible? (1)
|
29
|
+
|
30
|
+
0.9.0 thru 1.2 1991-1995 CWI yes
|
31
|
+
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
|
32
|
+
1.6 1.5.2 2000 CNRI no
|
33
|
+
2.0 1.6 2000 BeOpen.com no
|
34
|
+
1.6.1 1.6 2001 CNRI yes (2)
|
35
|
+
2.1 2.0+1.6.1 2001 PSF no
|
36
|
+
2.0.1 2.0+1.6.1 2001 PSF yes
|
37
|
+
2.1.1 2.1+2.0.1 2001 PSF yes
|
38
|
+
2.1.2 2.1.1 2002 PSF yes
|
39
|
+
2.1.3 2.1.2 2002 PSF yes
|
40
|
+
2.2 and above 2.1.1 2001-now PSF yes
|
41
|
+
|
42
|
+
Footnotes:
|
43
|
+
|
44
|
+
(1) GPL-compatible doesn't mean that we're distributing Python under
|
45
|
+
the GPL. All Python licenses, unlike the GPL, let you distribute
|
46
|
+
a modified version without making your changes open source. The
|
47
|
+
GPL-compatible licenses make it possible to combine Python with
|
48
|
+
other software that is released under the GPL; the others don't.
|
49
|
+
|
50
|
+
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
|
51
|
+
because its license has a choice of law clause. According to
|
52
|
+
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
|
53
|
+
is "not incompatible" with the GPL.
|
54
|
+
|
55
|
+
Thanks to the many outside volunteers who have worked under Guido's
|
56
|
+
direction to make these releases possible.
|
57
|
+
|
58
|
+
|
59
|
+
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
|
60
|
+
===============================================================
|
61
|
+
|
62
|
+
Python software and documentation are licensed under the
|
63
|
+
Python Software Foundation License Version 2.
|
64
|
+
|
65
|
+
Starting with Python 3.8.6, examples, recipes, and other code in
|
66
|
+
the documentation are dual licensed under the PSF License Version 2
|
67
|
+
and the Zero-Clause BSD license.
|
68
|
+
|
69
|
+
Some software incorporated into Python is under different licenses.
|
70
|
+
The licenses are listed with code falling under that license.
|
71
|
+
|
72
|
+
|
73
|
+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
74
|
+
--------------------------------------------
|
75
|
+
|
76
|
+
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
77
|
+
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
78
|
+
otherwise using this software ("Python") in source or binary form and
|
79
|
+
its associated documentation.
|
80
|
+
|
81
|
+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
82
|
+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
83
|
+
analyze, test, perform and/or display publicly, prepare derivative works,
|
84
|
+
distribute, and otherwise use Python alone or in any derivative version,
|
85
|
+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
86
|
+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
87
|
+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Python Software Foundation;
|
88
|
+
All Rights Reserved" are retained in Python alone or in any derivative version
|
89
|
+
prepared by Licensee.
|
90
|
+
|
91
|
+
3. In the event Licensee prepares a derivative work that is based on
|
92
|
+
or incorporates Python or any part thereof, and wants to make
|
93
|
+
the derivative work available to others as provided herein, then
|
94
|
+
Licensee hereby agrees to include in any such work a brief summary of
|
95
|
+
the changes made to Python.
|
96
|
+
|
97
|
+
4. PSF is making Python available to Licensee on an "AS IS"
|
98
|
+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
99
|
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
100
|
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
101
|
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
102
|
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
103
|
+
|
104
|
+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
105
|
+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
106
|
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
107
|
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
108
|
+
|
109
|
+
6. This License Agreement will automatically terminate upon a material
|
110
|
+
breach of its terms and conditions.
|
111
|
+
|
112
|
+
7. Nothing in this License Agreement shall be deemed to create any
|
113
|
+
relationship of agency, partnership, or joint venture between PSF and
|
114
|
+
Licensee. This License Agreement does not grant permission to use PSF
|
115
|
+
trademarks or trade name in a trademark sense to endorse or promote
|
116
|
+
products or services of Licensee, or any third party.
|
117
|
+
|
118
|
+
8. By copying, installing or otherwise using Python, Licensee
|
119
|
+
agrees to be bound by the terms and conditions of this License
|
120
|
+
Agreement.
|
121
|
+
|
122
|
+
|
123
|
+
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
|
124
|
+
-------------------------------------------
|
125
|
+
|
126
|
+
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
|
127
|
+
|
128
|
+
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
|
129
|
+
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
|
130
|
+
Individual or Organization ("Licensee") accessing and otherwise using
|
131
|
+
this software in source or binary form and its associated
|
132
|
+
documentation ("the Software").
|
133
|
+
|
134
|
+
2. Subject to the terms and conditions of this BeOpen Python License
|
135
|
+
Agreement, BeOpen hereby grants Licensee a non-exclusive,
|
136
|
+
royalty-free, world-wide license to reproduce, analyze, test, perform
|
137
|
+
and/or display publicly, prepare derivative works, distribute, and
|
138
|
+
otherwise use the Software alone or in any derivative version,
|
139
|
+
provided, however, that the BeOpen Python License is retained in the
|
140
|
+
Software, alone or in any derivative version prepared by Licensee.
|
141
|
+
|
142
|
+
3. BeOpen is making the Software available to Licensee on an "AS IS"
|
143
|
+
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
144
|
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
|
145
|
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
146
|
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
|
147
|
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
148
|
+
|
149
|
+
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
|
150
|
+
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
|
151
|
+
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
|
152
|
+
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
153
|
+
|
154
|
+
5. This License Agreement will automatically terminate upon a material
|
155
|
+
breach of its terms and conditions.
|
156
|
+
|
157
|
+
6. This License Agreement shall be governed by and interpreted in all
|
158
|
+
respects by the law of the State of California, excluding conflict of
|
159
|
+
law provisions. Nothing in this License Agreement shall be deemed to
|
160
|
+
create any relationship of agency, partnership, or joint venture
|
161
|
+
between BeOpen and Licensee. This License Agreement does not grant
|
162
|
+
permission to use BeOpen trademarks or trade names in a trademark
|
163
|
+
sense to endorse or promote products or services of Licensee, or any
|
164
|
+
third party. As an exception, the "BeOpen Python" logos available at
|
165
|
+
http://www.pythonlabs.com/logos.html may be used according to the
|
166
|
+
permissions granted on that web page.
|
167
|
+
|
168
|
+
7. By copying, installing or otherwise using the software, Licensee
|
169
|
+
agrees to be bound by the terms and conditions of this License
|
170
|
+
Agreement.
|
171
|
+
|
172
|
+
|
173
|
+
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
|
174
|
+
---------------------------------------
|
175
|
+
|
176
|
+
1. This LICENSE AGREEMENT is between the Corporation for National
|
177
|
+
Research Initiatives, having an office at 1895 Preston White Drive,
|
178
|
+
Reston, VA 20191 ("CNRI"), and the Individual or Organization
|
179
|
+
("Licensee") accessing and otherwise using Python 1.6.1 software in
|
180
|
+
source or binary form and its associated documentation.
|
181
|
+
|
182
|
+
2. Subject to the terms and conditions of this License Agreement, CNRI
|
183
|
+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
184
|
+
license to reproduce, analyze, test, perform and/or display publicly,
|
185
|
+
prepare derivative works, distribute, and otherwise use Python 1.6.1
|
186
|
+
alone or in any derivative version, provided, however, that CNRI's
|
187
|
+
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
|
188
|
+
1995-2001 Corporation for National Research Initiatives; All Rights
|
189
|
+
Reserved" are retained in Python 1.6.1 alone or in any derivative
|
190
|
+
version prepared by Licensee. Alternately, in lieu of CNRI's License
|
191
|
+
Agreement, Licensee may substitute the following text (omitting the
|
192
|
+
quotes): "Python 1.6.1 is made available subject to the terms and
|
193
|
+
conditions in CNRI's License Agreement. This Agreement together with
|
194
|
+
Python 1.6.1 may be located on the internet using the following
|
195
|
+
unique, persistent identifier (known as a handle): 1895.22/1013. This
|
196
|
+
Agreement may also be obtained from a proxy server on the internet
|
197
|
+
using the following URL: http://hdl.handle.net/1895.22/1013".
|
198
|
+
|
199
|
+
3. In the event Licensee prepares a derivative work that is based on
|
200
|
+
or incorporates Python 1.6.1 or any part thereof, and wants to make
|
201
|
+
the derivative work available to others as provided herein, then
|
202
|
+
Licensee hereby agrees to include in any such work a brief summary of
|
203
|
+
the changes made to Python 1.6.1.
|
204
|
+
|
205
|
+
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
|
206
|
+
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
207
|
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
|
208
|
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
209
|
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
|
210
|
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
211
|
+
|
212
|
+
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
213
|
+
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
214
|
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
|
215
|
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
216
|
+
|
217
|
+
6. This License Agreement will automatically terminate upon a material
|
218
|
+
breach of its terms and conditions.
|
219
|
+
|
220
|
+
7. This License Agreement shall be governed by the federal
|
221
|
+
intellectual property law of the United States, including without
|
222
|
+
limitation the federal copyright law, and, to the extent such
|
223
|
+
U.S. federal law does not apply, by the law of the Commonwealth of
|
224
|
+
Virginia, excluding Virginia's conflict of law provisions.
|
225
|
+
Notwithstanding the foregoing, with regard to derivative works based
|
226
|
+
on Python 1.6.1 that incorporate non-separable material that was
|
227
|
+
previously distributed under the GNU General Public License (GPL), the
|
228
|
+
law of the Commonwealth of Virginia shall govern this License
|
229
|
+
Agreement only as to issues arising under or with respect to
|
230
|
+
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
|
231
|
+
License Agreement shall be deemed to create any relationship of
|
232
|
+
agency, partnership, or joint venture between CNRI and Licensee. This
|
233
|
+
License Agreement does not grant permission to use CNRI trademarks or
|
234
|
+
trade name in a trademark sense to endorse or promote products or
|
235
|
+
services of Licensee, or any third party.
|
236
|
+
|
237
|
+
8. By clicking on the "ACCEPT" button where indicated, or by copying,
|
238
|
+
installing or otherwise using Python 1.6.1, Licensee agrees to be
|
239
|
+
bound by the terms and conditions of this License Agreement.
|
240
|
+
|
241
|
+
ACCEPT
|
242
|
+
|
243
|
+
|
244
|
+
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
|
245
|
+
--------------------------------------------------
|
246
|
+
|
247
|
+
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
|
248
|
+
The Netherlands. All rights reserved.
|
249
|
+
|
250
|
+
Permission to use, copy, modify, and distribute this software and its
|
251
|
+
documentation for any purpose and without fee is hereby granted,
|
252
|
+
provided that the above copyright notice appear in all copies and that
|
253
|
+
both that copyright notice and this permission notice appear in
|
254
|
+
supporting documentation, and that the name of Stichting Mathematisch
|
255
|
+
Centrum or CWI not be used in advertising or publicity pertaining to
|
256
|
+
distribution of the software without specific, written prior
|
257
|
+
permission.
|
258
|
+
|
259
|
+
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
260
|
+
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
261
|
+
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
262
|
+
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
263
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
264
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
265
|
+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
266
|
+
|
267
|
+
ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION
|
268
|
+
----------------------------------------------------------------------
|
269
|
+
|
270
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
271
|
+
purpose with or without fee is hereby granted.
|
272
|
+
|
273
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
274
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
275
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
276
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
277
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
278
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
279
|
+
PERFORMANCE OF THIS SOFTWARE.
|
omlish/dataclasses/impl/init.py
CHANGED
@@ -130,9 +130,17 @@ class InitBuilder:
|
|
130
130
|
cas = ', '.join(p.name for p in csig.parameters.values())
|
131
131
|
body_lines.append(f'if not {cn}({cas}): raise __dataclass_CheckError__')
|
132
132
|
|
133
|
-
|
133
|
+
inits = self._info.merged_metadata.get(Init, [])
|
134
|
+
mro_dct = lang.build_mro_dict(self._info.cls)
|
135
|
+
mro_v_ids = set(map(id, mro_dct.values()))
|
136
|
+
props_by_fget_id = {id(v.fget): v for v in mro_dct.values() if isinstance(v, property) and v.fget is not None}
|
137
|
+
for i, obj in enumerate(inits):
|
138
|
+
if (obj_id := id(obj)) not in mro_v_ids and obj_id in props_by_fget_id:
|
139
|
+
obj = props_by_fget_id[obj_id].__get__
|
140
|
+
elif isinstance(obj, property):
|
141
|
+
obj = obj.__get__
|
134
142
|
cn = f'__dataclass_init_{i}__'
|
135
|
-
locals[cn] =
|
143
|
+
locals[cn] = obj
|
136
144
|
body_lines.append(f'{cn}({self._self_name})')
|
137
145
|
|
138
146
|
if not body_lines:
|
@@ -149,7 +149,7 @@ class ClassInfo:
|
|
149
149
|
|
150
150
|
@cached.property
|
151
151
|
def generic_mro_lookup(self) -> ta.Mapping[type, rfl.Type]:
|
152
|
-
return col.
|
152
|
+
return col.make_map(((check.not_none(rfl.get_concrete_type(g)), g) for g in self.generic_mro), strict=True)
|
153
153
|
|
154
154
|
@cached.property
|
155
155
|
def generic_replaced_field_types(self) -> ta.Mapping[str, rfl.Type]:
|
omlish/dataclasses/utils.py
CHANGED
@@ -4,6 +4,8 @@ import types
|
|
4
4
|
import typing as ta
|
5
5
|
|
6
6
|
from .. import check
|
7
|
+
from .impl.metadata import METADATA_ATTR
|
8
|
+
from .impl.metadata import UserMetadata
|
7
9
|
from .impl.params import DEFAULT_FIELD_EXTRAS
|
8
10
|
from .impl.params import FieldExtras
|
9
11
|
from .impl.params import get_field_extras
|
@@ -50,6 +52,13 @@ def chain_metadata(*mds: ta.Mapping) -> types.MappingProxyType:
|
|
50
52
|
return types.MappingProxyType(collections.ChainMap(*mds)) # type: ignore # noqa
|
51
53
|
|
52
54
|
|
55
|
+
def update_class_metadata(cls: type[T], *args: ta.Any) -> type[T]:
|
56
|
+
check.isinstance(cls, type)
|
57
|
+
setattr(cls, METADATA_ATTR, md := getattr(cls, METADATA_ATTR, {}))
|
58
|
+
md.setdefault(UserMetadata, []).extend(args)
|
59
|
+
return cls
|
60
|
+
|
61
|
+
|
53
62
|
def update_field_metadata(f: dc.Field, nmd: ta.Mapping) -> dc.Field:
|
54
63
|
check.isinstance(f, dc.Field)
|
55
64
|
f.metadata = chain_metadata(nmd, f.metadata)
|
@@ -79,9 +88,13 @@ def update_fields(
|
|
79
88
|
|
80
89
|
else:
|
81
90
|
for a in fields:
|
82
|
-
|
83
|
-
|
84
|
-
|
91
|
+
try:
|
92
|
+
v = cls.__dict__[a]
|
93
|
+
except KeyError:
|
94
|
+
v = dc.field()
|
95
|
+
else:
|
96
|
+
if not isinstance(v, dc.Field):
|
97
|
+
v = dc.field(default=v)
|
85
98
|
setattr(cls, a, fn(a, v))
|
86
99
|
|
87
100
|
return cls
|
omlish/diag/pycharm.py
CHANGED
@@ -17,6 +17,16 @@ else:
|
|
17
17
|
##
|
18
18
|
|
19
19
|
|
20
|
+
PYCHARM_HOSTED_ENV_VAR = 'PYCHARM_HOSTED'
|
21
|
+
|
22
|
+
|
23
|
+
def is_pycharm_hosted() -> bool:
|
24
|
+
return PYCHARM_HOSTED_ENV_VAR in os.environ
|
25
|
+
|
26
|
+
|
27
|
+
##
|
28
|
+
|
29
|
+
|
20
30
|
PYCHARM_HOME = '/Applications/PyCharm.app'
|
21
31
|
|
22
32
|
|
@@ -45,6 +55,53 @@ def get_pycharm_version() -> str | None:
|
|
45
55
|
##
|
46
56
|
|
47
57
|
|
58
|
+
def _import_pydevd_pycharm(*, version: str | None = None) -> ta.Any:
|
59
|
+
if (
|
60
|
+
'pydevd_pycharm' in sys.modules or
|
61
|
+
(version is None and lang.can_import('pydevd_pycharm'))
|
62
|
+
):
|
63
|
+
# Can't unload, nothing we can do
|
64
|
+
import pydevd_pycharm # noqa
|
65
|
+
return pydevd_pycharm
|
66
|
+
|
67
|
+
proc = subprocess.run([ # noqa
|
68
|
+
sys.executable,
|
69
|
+
'-m', 'pip',
|
70
|
+
'show',
|
71
|
+
'pydevd_pycharm',
|
72
|
+
], stdout=subprocess.PIPE)
|
73
|
+
|
74
|
+
if not proc.returncode:
|
75
|
+
info = {
|
76
|
+
k: v.strip()
|
77
|
+
for l in proc.stdout.decode().splitlines()
|
78
|
+
if (s := l.strip())
|
79
|
+
for k, _, v in [s.partition(':')]
|
80
|
+
}
|
81
|
+
|
82
|
+
installed_version = info['Version']
|
83
|
+
if installed_version == version:
|
84
|
+
import pydevd_pycharm # noqa
|
85
|
+
return pydevd_pycharm
|
86
|
+
|
87
|
+
subprocess.check_call([
|
88
|
+
sys.executable,
|
89
|
+
'-m', 'pip',
|
90
|
+
'uninstall', '-y',
|
91
|
+
'pydevd_pycharm',
|
92
|
+
])
|
93
|
+
|
94
|
+
subprocess.check_call([
|
95
|
+
sys.executable,
|
96
|
+
'-m', 'pip',
|
97
|
+
'install',
|
98
|
+
'pydevd_pycharm' + (f'=={version}' if version is not None else ''),
|
99
|
+
])
|
100
|
+
|
101
|
+
import pydevd_pycharm # noqa
|
102
|
+
return pydevd_pycharm
|
103
|
+
|
104
|
+
|
48
105
|
def pycharm_remote_debugger_attach(
|
49
106
|
host: str | None,
|
50
107
|
port: int,
|
@@ -56,25 +113,27 @@ def pycharm_remote_debugger_attach(
|
|
56
113
|
# check.non_empty_str(version)
|
57
114
|
|
58
115
|
if host is None:
|
59
|
-
if
|
116
|
+
if (
|
117
|
+
sys.platform == 'linux' and
|
118
|
+
docker.is_likely_in_docker() and
|
119
|
+
docker.get_docker_host_platform() == 'darwin'
|
120
|
+
):
|
60
121
|
host = docker.DOCKER_FOR_MAC_HOSTNAME
|
61
122
|
else:
|
62
123
|
host = 'localhost'
|
63
124
|
|
64
|
-
|
125
|
+
if ta.TYPE_CHECKING:
|
65
126
|
import pydevd_pycharm # noqa
|
66
|
-
|
67
|
-
|
68
|
-
sys.executable,
|
69
|
-
'-mpip',
|
70
|
-
'install',
|
71
|
-
'pydevd-pycharm' + (f'~={version}' if version is not None else ''),
|
72
|
-
])
|
127
|
+
else:
|
128
|
+
pydevd_pycharm = _import_pydevd_pycharm(version=version)
|
73
129
|
|
74
|
-
import pydevd_pycharm # noqa
|
75
130
|
pydevd_pycharm.settrace(
|
76
131
|
host,
|
77
132
|
port=port,
|
78
133
|
stdoutToServer=True,
|
79
134
|
stderrToServer=True,
|
80
135
|
)
|
136
|
+
|
137
|
+
|
138
|
+
if __name__ == '__main__':
|
139
|
+
print(get_pycharm_version())
|
omlish/docker.py
CHANGED
@@ -15,6 +15,7 @@ apil="application/vnd.docker.distribution.manifest.list.v2+json"
|
|
15
15
|
curl -H "Accept: ${api}" -H "Accept: ${apil}" -H "Authorization: Bearer $token" -s "https://registry-1.docker.io/v2/${repo}/manifests/latest" | jq .
|
16
16
|
""" # noqa
|
17
17
|
import datetime
|
18
|
+
import os
|
18
19
|
import re
|
19
20
|
import shlex
|
20
21
|
import subprocess
|
@@ -38,15 +39,12 @@ else:
|
|
38
39
|
|
39
40
|
|
40
41
|
@dc.dataclass(frozen=True)
|
42
|
+
@msh.update_object_metadata(field_naming=msh.Naming.CAMEL, unknown_field='x')
|
43
|
+
@msh.update_fields_metadata(['id'], name='ID')
|
41
44
|
class PsItem(lang.Final):
|
42
|
-
dc.metadata(msh.ObjectMetadata(
|
43
|
-
field_naming=msh.Naming.CAMEL,
|
44
|
-
unknown_field='x',
|
45
|
-
))
|
46
|
-
|
47
45
|
command: str
|
48
46
|
created_at: datetime.datetime
|
49
|
-
id: str
|
47
|
+
id: str
|
50
48
|
image: str
|
51
49
|
labels: str
|
52
50
|
local_volumes: str
|
@@ -101,12 +99,8 @@ def cli_ps() -> list[PsItem]:
|
|
101
99
|
|
102
100
|
|
103
101
|
@dc.dataclass(frozen=True)
|
102
|
+
@msh.update_object_metadata(field_naming=msh.Naming.CAMEL, unknown_field='x')
|
104
103
|
class Inspect(lang.Final):
|
105
|
-
dc.metadata(msh.ObjectMetadata(
|
106
|
-
field_naming=msh.Naming.CAMEL,
|
107
|
-
unknown_field='x',
|
108
|
-
))
|
109
|
-
|
110
104
|
id: str
|
111
105
|
created: datetime.datetime
|
112
106
|
|
@@ -186,3 +180,14 @@ def is_likely_in_docker() -> bool:
|
|
186
180
|
with open('/proc/mounts') as f: # type: ignore
|
187
181
|
ls = f.readlines()
|
188
182
|
return any(_LIKELY_IN_DOCKER_PATTERN.match(l) for l in ls)
|
183
|
+
|
184
|
+
|
185
|
+
##
|
186
|
+
|
187
|
+
|
188
|
+
# Set by pyproject, docker-dev script
|
189
|
+
DOCKER_HOST_PLATFORM_KEY = 'DOCKER_HOST_PLATFORM'
|
190
|
+
|
191
|
+
|
192
|
+
def get_docker_host_platform() -> str | None:
|
193
|
+
return os.environ.get(DOCKER_HOST_PLATFORM_KEY)
|
omlish/genmachine.py
CHANGED
omlish/graphs/trees.py
CHANGED
@@ -190,7 +190,7 @@ class BasicTreeAnalysis(ta.Generic[NodeT]):
|
|
190
190
|
e: ta.Any
|
191
191
|
d: ta.Any
|
192
192
|
if identity:
|
193
|
-
e, d = id, col.
|
193
|
+
e, d = id, col.make_map(((id(n), n) for n, _ in pairs), strict=True)
|
194
194
|
else:
|
195
195
|
e, d = lang.identity, lang.identity
|
196
196
|
tsd = {e(n): {e(p)} for n, p in parents_by_node.items()}
|
omlish/lang/__init__.py
CHANGED
@@ -79,7 +79,7 @@ from .descriptors import ( # noqa
|
|
79
79
|
unwrap_func,
|
80
80
|
unwrap_func_with_partials,
|
81
81
|
unwrap_method_descriptors,
|
82
|
-
|
82
|
+
update_wrapper,
|
83
83
|
)
|
84
84
|
|
85
85
|
from .exceptions import ( # noqa
|
@@ -154,6 +154,18 @@ from .objects import ( # noqa
|
|
154
154
|
super_meta,
|
155
155
|
)
|
156
156
|
|
157
|
+
from .resolving import ( # noqa
|
158
|
+
Resolvable,
|
159
|
+
ResolvableClassNameError,
|
160
|
+
get_cls_fqcn,
|
161
|
+
get_fqcn_cls,
|
162
|
+
)
|
163
|
+
|
164
|
+
from .resources import ( # noqa
|
165
|
+
RelativeResource,
|
166
|
+
get_relative_resources,
|
167
|
+
)
|
168
|
+
|
157
169
|
from .strings import ( # noqa
|
158
170
|
BOOL_FALSE_STRINGS,
|
159
171
|
BOOL_STRINGS,
|
@@ -190,6 +202,7 @@ from .typing import ( # noqa
|
|
190
202
|
Func1,
|
191
203
|
Func2,
|
192
204
|
Func3,
|
205
|
+
SequenceNotStr,
|
193
206
|
protocol_check,
|
194
207
|
typed_lambda,
|
195
208
|
typed_partial,
|
omlish/lang/cached.py
CHANGED
@@ -220,7 +220,7 @@ def cached_function(fn=None, **kwargs): # noqa
|
|
220
220
|
##
|
221
221
|
|
222
222
|
|
223
|
-
class _CachedProperty:
|
223
|
+
class _CachedProperty(property):
|
224
224
|
def __init__(
|
225
225
|
self,
|
226
226
|
fn,
|
@@ -229,9 +229,9 @@ class _CachedProperty:
|
|
229
229
|
ignore_if=lambda _: False,
|
230
230
|
clear_on_init=False,
|
231
231
|
):
|
232
|
-
super().__init__()
|
233
232
|
if isinstance(fn, property):
|
234
233
|
fn = fn.fget
|
234
|
+
super().__init__(fn)
|
235
235
|
self._fn = fn
|
236
236
|
self._ignore_if = ignore_if
|
237
237
|
self._name = name
|
@@ -265,6 +265,9 @@ class _CachedProperty:
|
|
265
265
|
return
|
266
266
|
raise TypeError(self._name)
|
267
267
|
|
268
|
+
def __delete__(self, instance):
|
269
|
+
raise TypeError
|
270
|
+
|
268
271
|
|
269
272
|
def cached_property(fn=None, **kwargs): # noqa
|
270
273
|
if fn is None:
|
omlish/lang/descriptors.py
CHANGED
@@ -91,21 +91,38 @@ def unwrap_func_with_partials(fn: ta.Callable) -> tuple[ta.Callable, list[functo
|
|
91
91
|
##
|
92
92
|
|
93
93
|
|
94
|
-
|
94
|
+
def update_wrapper(
|
95
|
+
wrapper: T,
|
96
|
+
wrapped: ta.Any,
|
97
|
+
assigned: ta.Iterable[str] = functools.WRAPPER_ASSIGNMENTS,
|
98
|
+
updated: ta.Iterable[str] = functools.WRAPPER_UPDATES,
|
99
|
+
*,
|
100
|
+
filter: ta.Iterable[str] | None = None, # noqa
|
101
|
+
getattr: ta.Callable = getattr, # noqa
|
102
|
+
setattr: ta.Callable = setattr, # noqa
|
103
|
+
) -> T:
|
104
|
+
if filter:
|
105
|
+
if isinstance(filter, str):
|
106
|
+
filter = [filter] # noqa
|
107
|
+
assigned = tuple(a for a in assigned if a not in filter)
|
108
|
+
updated = tuple(a for a in updated if a not in filter)
|
109
|
+
|
110
|
+
for attr in assigned:
|
111
|
+
try:
|
112
|
+
value = getattr(wrapped, attr)
|
113
|
+
except AttributeError:
|
114
|
+
pass
|
115
|
+
else:
|
116
|
+
setattr(wrapper, attr, value)
|
117
|
+
|
118
|
+
for attr in updated:
|
119
|
+
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
|
95
120
|
|
121
|
+
# Issue #17482: set __wrapped__ last so we don't inadvertently copy it from the wrapped function when updating
|
122
|
+
# __dict__
|
123
|
+
setattr(wrapper, '__wrapped__', wrapped)
|
96
124
|
|
97
|
-
|
98
|
-
wrapper,
|
99
|
-
wrapped,
|
100
|
-
assigned=functools.WRAPPER_ASSIGNMENTS,
|
101
|
-
updated=WRAPPER_UPDATES_EXCEPT_DICT,
|
102
|
-
):
|
103
|
-
return functools.update_wrapper(
|
104
|
-
wrapper,
|
105
|
-
wrapped,
|
106
|
-
assigned=assigned,
|
107
|
-
updated=updated,
|
108
|
-
)
|
125
|
+
return wrapper
|
109
126
|
|
110
127
|
|
111
128
|
##
|
@@ -118,7 +135,7 @@ class _decorator_descriptor: # noqa
|
|
118
135
|
if not _DECORATOR_HANDLES_UNBOUND_METHODS:
|
119
136
|
def __init__(self, wrapper, fn):
|
120
137
|
self._wrapper, self._fn = wrapper, fn
|
121
|
-
|
138
|
+
update_wrapper(self, fn, filter='__dict__')
|
122
139
|
|
123
140
|
def __get__(self, instance, owner=None):
|
124
141
|
return functools.update_wrapper(functools.partial(self._wrapper, fn := self._fn.__get__(instance, owner)), fn) # noqa
|
@@ -127,7 +144,7 @@ class _decorator_descriptor: # noqa
|
|
127
144
|
def __init__(self, wrapper, fn):
|
128
145
|
self._wrapper, self._fn = wrapper, fn
|
129
146
|
self._md = _has_method_descriptor(fn)
|
130
|
-
|
147
|
+
update_wrapper(self, fn, filter='__dict__')
|
131
148
|
|
132
149
|
def __get__(self, instance, owner=None):
|
133
150
|
fn = self._fn.__get__(instance, owner)
|
@@ -157,7 +174,7 @@ class _decorator_descriptor: # noqa
|
|
157
174
|
class _decorator: # noqa
|
158
175
|
def __init__(self, wrapper):
|
159
176
|
self._wrapper = wrapper
|
160
|
-
|
177
|
+
update_wrapper(self, wrapper, filter='__dict__')
|
161
178
|
|
162
179
|
def __repr__(self):
|
163
180
|
return f'{self.__class__.__name__}<{self._wrapper}>'
|