omlish 0.0.0.dev270__py3-none-any.whl → 0.0.0.dev271__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 CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev270'
2
- __revision__ = 'ac26cb82cb30f878a10324fe1bf518f6a0b4b87f'
1
+ __version__ = '0.0.0.dev271'
2
+ __revision__ = 'fc242f5a994ee5dd88268a5720ed88792d17c61f'
3
3
 
4
4
 
5
5
  #
@@ -11,6 +11,7 @@ import types
11
11
  import typing as ta
12
12
 
13
13
  from ... import check as check_
14
+ from ... import lang
14
15
  from .internals import PARAMS_ATTR
15
16
  from .internals import Params
16
17
  from .main import process_class
@@ -40,20 +41,26 @@ def field( # noqa
40
41
  check_type: bool | type | tuple[type | None, ...] | None = None,
41
42
  override: bool = False,
42
43
  repr_fn: ta.Callable[[ta.Any], str | None] | None = None,
44
+ repr_priority: int | None = None,
43
45
  frozen: bool | None = None,
44
46
  ): # -> dc.Field
45
47
  if default is not MISSING and default_factory is not MISSING:
46
48
  raise ValueError('cannot specify both default and default_factory')
47
49
 
48
- fx = FieldExtras(
50
+ fx = FieldExtras()
51
+ if metadata is not None:
52
+ fx = metadata.get(FieldExtras, fx)
53
+
54
+ fx = dc.replace(fx, **lang.opt_kw(
49
55
  derive=derive,
50
56
  coerce=coerce,
51
57
  validate=validate,
52
58
  check_type=check_type,
53
59
  override=override,
54
60
  repr_fn=repr_fn,
61
+ repr_priority=repr_priority,
55
62
  frozen=frozen,
56
- )
63
+ ))
57
64
 
58
65
  md: ta.Mapping = {FieldExtras: fx}
59
66
  if metadata is not None:
@@ -53,6 +53,7 @@ class FieldExtras(lang.Final):
53
53
  check_type: bool | type | tuple[type | None, ...] | None = None
54
54
  override: bool = False
55
55
  repr_fn: ta.Callable[[ta.Any], str | None] | None = None
56
+ repr_priority: int | None = None
56
57
  frozen: bool | None = None # TODO
57
58
 
58
59
 
@@ -14,6 +14,9 @@ def repr_fn(
14
14
  globals: Namespace, # noqa
15
15
  ) -> ta.Callable:
16
16
  locals: dict[str, ta.Any] = {} # noqa
17
+
18
+ fields = sorted(fields, key=lambda f: get_field_extras(f).repr_priority or 0)
19
+
17
20
  if any(get_field_extras(f).repr_fn is not None for f in fields):
18
21
  lst: list[str] = []
19
22
  for f in fields:
@@ -22,17 +25,20 @@ def repr_fn(
22
25
  lst.append(f"if (r := {fn_name}(self.{f.name})) is not None: l.append(f'{f.name}={{r}}')")
23
26
  else:
24
27
  lst.append(f"l.append(f'{f.name}={{self.{f.name}!r}}')")
28
+
25
29
  src = [
26
30
  'l = []',
27
31
  *lst,
28
32
  'return f"{self.__class__.__qualname__}({", ".join(l)})"',
29
33
  ]
34
+
30
35
  else:
31
36
  src = [
32
37
  'return f"{self.__class__.__qualname__}(' +
33
38
  ', '.join([f'{f.name}={{self.{f.name}!r}}' for f in fields]) +
34
39
  ')"',
35
40
  ]
41
+
36
42
  fn = create_fn(
37
43
  '__repr__',
38
44
  ('self',),
@@ -40,6 +46,7 @@ def repr_fn(
40
46
  globals=globals,
41
47
  locals=locals,
42
48
  )
49
+
43
50
  return reprlib.recursive_repr()(fn)
44
51
 
45
52
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: omlish
3
- Version: 0.0.0.dev270
3
+ Version: 0.0.0.dev271
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=x26AIwDzScUvnX-p4xlq6Zc5QYrAo0Vmgf1qHc1KL_M,8253
2
- omlish/__about__.py,sha256=OR-PRiAN7dudUKnLMzl2lt9Y5bh8Gy1c1V-wJvtHqLA,3380
2
+ omlish/__about__.py,sha256=a-BsHYkG1XmGNuahLQVSE6wR7i-00PDzWGTjEenZsC0,3380
3
3
  omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
4
4
  omlish/c3.py,sha256=rer-TPOFDU6fYq_AWio_AmA-ckZ8JDY5shIzQ_yXfzA,8414
5
5
  omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
@@ -206,7 +206,7 @@ omlish/dataclasses/static.py,sha256=6pZG2iTR9NN8pKm-5ukDABnaVlTKFOzMwkg-rbxURoo,
206
206
  omlish/dataclasses/utils.py,sha256=BTXYyH0enSEP5kWxMnPTJ8_UPd7h4wF2RVPITNC8H4M,3872
207
207
  omlish/dataclasses/impl/LICENSE,sha256=Oy-B_iHRgcSZxZolbI4ZaEVdZonSaaqFNzv7avQdo78,13936
208
208
  omlish/dataclasses/impl/__init__.py,sha256=zqGBC5gSbjJxaqG_zS1LL1PX-zAfhIua8UqOE4IwO2k,789
209
- omlish/dataclasses/impl/api.py,sha256=RhU4f50GVdn-dxilia8NA3F7VIm2R5z78pFfpIVXPRQ,6635
209
+ omlish/dataclasses/impl/api.py,sha256=Sl3DhCLn8KCvsXAOahr7VP_EH9XqBu9TBt3MQ9WqLbo,6849
210
210
  omlish/dataclasses/impl/as_.py,sha256=CD-t7hkC1EP2F_jvZKIA_cVoDuwZ-Ln_xC4fJumPYX0,2598
211
211
  omlish/dataclasses/impl/copy.py,sha256=Tn8_n6Vohs-w4otbGdubBEvhd3TsSTaM3EfNGdS2LYo,591
212
212
  omlish/dataclasses/impl/descriptors.py,sha256=jSYNkKdy2rKddGpQqRwNuhw-ggpcvp_SWHpLwIWPOzc,2474
@@ -221,11 +221,11 @@ omlish/dataclasses/impl/metaclass.py,sha256=ebxJr3j8d_wz-fc7mvhWtJ6wJgnxVV6rVOQd
221
221
  omlish/dataclasses/impl/metadata.py,sha256=4veWwTr-aA0KP-Y1cPEeOcXHup9EKJTYNJ0ozIxtzD4,1401
222
222
  omlish/dataclasses/impl/order.py,sha256=zWvWDkSTym8cc7vO1cLHqcBhhjOlucHOCUVJcdh4jt0,1369
223
223
  omlish/dataclasses/impl/overrides.py,sha256=g9aCzaDDKyek8-yXRvtAcu1B1nCphWDYr4InHDlgbKk,1732
224
- omlish/dataclasses/impl/params.py,sha256=9EHn7PxqPVtRPcNDNDCsbcmxvkezWR5LzLLxCua2Vok,2946
224
+ omlish/dataclasses/impl/params.py,sha256=lmZkxZlZWPEPXmC-__P_3ZZeyL7IoQxli15mM3kUUsU,2983
225
225
  omlish/dataclasses/impl/processing.py,sha256=DFxyFjL_h3awRyF_5eyTnB8QkuApx7Zc4QFnVoltlao,459
226
226
  omlish/dataclasses/impl/reflect.py,sha256=1PTxx3ycsWhC3oAV71mW-ZquDRwa2-t9uIaKFO8ab8U,5468
227
227
  omlish/dataclasses/impl/replace.py,sha256=wS9GHX4fIwaPv1JBJzIewdBfXyK3X3V7_t55Da87dYo,1217
228
- omlish/dataclasses/impl/repr.py,sha256=oLXBTxqp88NKmz82HrJeGiTEiwK4l5LlXQT9Q0-tX3c,1605
228
+ omlish/dataclasses/impl/repr.py,sha256=D6Rnz0tWf8Qy9abIFVV0x1UQFF9ERJd4VsyHmQ9Y2g0,1693
229
229
  omlish/dataclasses/impl/simple.py,sha256=Q272TYXifB5iKtydByxyzraeQHX6aXDY0VKO1-AKBF4,1771
230
230
  omlish/dataclasses/impl/slots.py,sha256=qXRLbtFWUs_2UV1fFUdv53_6fBLKJ_8McjNiP9YQlGM,5264
231
231
  omlish/dataclasses/impl/utils.py,sha256=aER2iL3UAtgS1BdLuEvTr9Tr2wC28wk1kiOeO-jIymw,6138
@@ -776,9 +776,9 @@ omlish/text/parts.py,sha256=Q9NvoyEGQKIWgiPD4D_Qc66cWAuyEKE033dT9m7c3Wk,6662
776
776
  omlish/text/random.py,sha256=8feS5JE_tSjYlMl-lp0j93kCfzBae9AM2cXlRLebXMA,199
777
777
  omlish/text/go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
778
778
  omlish/text/go/quoting.py,sha256=N9EYdnFdEX_A8fOviH-1w4jwV3XOQ7VU2WsoUNubYVY,9137
779
- omlish-0.0.0.dev270.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
780
- omlish-0.0.0.dev270.dist-info/METADATA,sha256=yrRv07ARNclD2q_004yblEKJRqGAi5VuRPhmU21-rhU,4198
781
- omlish-0.0.0.dev270.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
782
- omlish-0.0.0.dev270.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
783
- omlish-0.0.0.dev270.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
784
- omlish-0.0.0.dev270.dist-info/RECORD,,
779
+ omlish-0.0.0.dev271.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
780
+ omlish-0.0.0.dev271.dist-info/METADATA,sha256=SXISrSK-Lmc1Z9EwMNS_ex2iPPZeBFhAoayeCdlukGw,4198
781
+ omlish-0.0.0.dev271.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
782
+ omlish-0.0.0.dev271.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
783
+ omlish-0.0.0.dev271.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
784
+ omlish-0.0.0.dev271.dist-info/RECORD,,