omdev 0.0.0.dev120__py3-none-any.whl → 0.0.0.dev122__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.
omdev/scripts/interp.py CHANGED
@@ -29,6 +29,7 @@ import shutil
29
29
  import subprocess
30
30
  import sys
31
31
  import threading
32
+ import types
32
33
  import typing as ta
33
34
 
34
35
 
@@ -488,7 +489,7 @@ class _cached_nullary: # noqa
488
489
  return bound
489
490
 
490
491
 
491
- def cached_nullary(fn: ta.Callable[..., T]) -> ta.Callable[..., T]:
492
+ def cached_nullary(fn): # ta.Callable[..., T]) -> ta.Callable[..., T]:
492
493
  return _cached_nullary(fn)
493
494
 
494
495
 
@@ -614,6 +615,14 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
614
615
  return it
615
616
 
616
617
 
618
+ def is_new_type(spec: ta.Any) -> bool:
619
+ if isinstance(ta.NewType, type):
620
+ return isinstance(spec, ta.NewType)
621
+ else:
622
+ # Before https://github.com/python/cpython/commit/c2f33dfc83ab270412bf243fb21f724037effa1a
623
+ return isinstance(spec, types.FunctionType) and spec.__code__ is ta.NewType.__code__.co_consts[1] # type: ignore # noqa
624
+
625
+
617
626
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
618
627
  seen = set()
619
628
  todo = list(reversed(cls.__subclasses__()))
@@ -629,7 +629,7 @@ def canonicalize_version(
629
629
  # 8. By copying, installing or otherwise using Python, Licensee agrees to be bound by the terms and conditions of this
630
630
  # License Agreement.
631
631
  #
632
- # https://github.com/python/cpython/blob/f5009b69e0cd94b990270e04e65b9d4d2b365844/Lib/tomllib/_parser.py
632
+ # https://github.com/python/cpython/blob/9ce90206b7a4649600218cf0bd4826db79c9a312/Lib/tomllib/_parser.py
633
633
 
634
634
 
635
635
  ##
@@ -776,7 +776,10 @@ def toml_loads(s: str, /, *, parse_float: TomlParseFloat = float) -> ta.Dict[str
776
776
  """Parse TOML from a string."""
777
777
 
778
778
  # The spec allows converting "\r\n" to "\n", even in string literals. Let's do so to simplify parsing.
779
- src = s.replace('\r\n', '\n')
779
+ try:
780
+ src = s.replace('\r\n', '\n')
781
+ except (AttributeError, TypeError):
782
+ raise TypeError(f"Expected str object, not '{type(s).__qualname__}'") from None
780
783
  pos = 0
781
784
  out = TomlOutput(TomlNestedDict(), TomlFlags())
782
785
  header: TomlKey = ()
@@ -1776,7 +1779,7 @@ class _cached_nullary: # noqa
1776
1779
  return bound
1777
1780
 
1778
1781
 
1779
- def cached_nullary(fn: ta.Callable[..., T]) -> ta.Callable[..., T]:
1782
+ def cached_nullary(fn): # ta.Callable[..., T]) -> ta.Callable[..., T]:
1780
1783
  return _cached_nullary(fn)
1781
1784
 
1782
1785
 
@@ -1902,6 +1905,14 @@ def get_optional_alias_arg(spec: ta.Any) -> ta.Any:
1902
1905
  return it
1903
1906
 
1904
1907
 
1908
+ def is_new_type(spec: ta.Any) -> bool:
1909
+ if isinstance(ta.NewType, type):
1910
+ return isinstance(spec, ta.NewType)
1911
+ else:
1912
+ # Before https://github.com/python/cpython/commit/c2f33dfc83ab270412bf243fb21f724037effa1a
1913
+ return isinstance(spec, types.FunctionType) and spec.__code__ is ta.NewType.__code__.co_consts[1] # type: ignore # noqa
1914
+
1915
+
1905
1916
  def deep_subclasses(cls: ta.Type[T]) -> ta.Iterator[ta.Type[T]]:
1906
1917
  seen = set()
1907
1918
  todo = list(reversed(cls.__subclasses__()))
omdev/toml/parser.py CHANGED
@@ -38,7 +38,7 @@
38
38
  # 8. By copying, installing or otherwise using Python, Licensee agrees to be bound by the terms and conditions of this
39
39
  # License Agreement.
40
40
  #
41
- # https://github.com/python/cpython/blob/f5009b69e0cd94b990270e04e65b9d4d2b365844/Lib/tomllib/_parser.py
41
+ # https://github.com/python/cpython/blob/9ce90206b7a4649600218cf0bd4826db79c9a312/Lib/tomllib/_parser.py
42
42
  # ruff: noqa: UP006 UP007
43
43
  import datetime
44
44
  import functools
@@ -197,7 +197,10 @@ def toml_loads(s: str, /, *, parse_float: TomlParseFloat = float) -> ta.Dict[str
197
197
  """Parse TOML from a string."""
198
198
 
199
199
  # The spec allows converting "\r\n" to "\n", even in string literals. Let's do so to simplify parsing.
200
- src = s.replace('\r\n', '\n')
200
+ try:
201
+ src = s.replace('\r\n', '\n')
202
+ except (AttributeError, TypeError):
203
+ raise TypeError(f"Expected str object, not '{type(s).__qualname__}'") from None
201
204
  pos = 0
202
205
  out = TomlOutput(TomlNestedDict(), TomlFlags())
203
206
  header: TomlKey = ()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev120
3
+ Version: 0.0.0.dev122
4
4
  Summary: omdev
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omlish ==0.0.0.dev120
15
+ Requires-Dist: omlish ==0.0.0.dev122
16
16
  Provides-Extra: all
17
17
  Requires-Dist: black ~=24.10 ; extra == 'all'
18
18
  Requires-Dist: pycparser ~=2.22 ; extra == 'all'
@@ -122,12 +122,12 @@ omdev/scripts/bumpversion.py,sha256=Kn7fo73Hs8uJh3Hi3EIyLOlzLPWAC6dwuD_lZ3cIzuY,
122
122
  omdev/scripts/execrss.py,sha256=mR0G0wERBYtQmVIn63lCIIFb5zkCM6X_XOENDFYDBKc,651
123
123
  omdev/scripts/exectime.py,sha256=sFb376GflU6s9gNX-2-we8hgH6w5MuQNS9g6i4SqJIo,610
124
124
  omdev/scripts/importtrace.py,sha256=Jbo3Yk2RAbE8_tJ97iTcVNpoxCJxrRb2tl1W_CV3NG0,14067
125
- omdev/scripts/interp.py,sha256=GM6VrG1Wd1vfwbAJr7fartN7hER_mnJknyX65o3jhkk,72665
126
- omdev/scripts/pyproject.py,sha256=x7gsWZ8h1gZ3Y_31-cKpOeT_uafAHPxFGdwxjh7Ha-I,173738
125
+ omdev/scripts/interp.py,sha256=pkQEle7G2FUd69baRvopjdi4KYwXbZpJBdgn60v1S0g,73043
126
+ omdev/scripts/pyproject.py,sha256=a6fG_cI-HGFxXcgtPU8K3ybD8P9d9FshhnI-ro5D6eo,174244
127
127
  omdev/scripts/slowcat.py,sha256=lssv4yrgJHiWfOiHkUut2p8E8Tq32zB-ujXESQxFFHY,2728
128
128
  omdev/scripts/tmpexec.py,sha256=WTYcf56Tj2qjYV14AWmV8SfT0u6Y8eIU6cKgQRvEK3c,1442
129
129
  omdev/toml/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
130
- omdev/toml/parser.py,sha256=84bn09uhYHwQGyfww6Rw6y1RxPAE_HDltODOSakcqDM,29186
130
+ omdev/toml/parser.py,sha256=ojhCYIk23ELRx2f9xUCwLTRq13UM6wrYGWoyxZBurlo,29327
131
131
  omdev/toml/writer.py,sha256=lk3on3YXVbWuLJa-xsOzOhs1bBAT1vXqw4mBbluZl_w,3040
132
132
  omdev/tools/__init__.py,sha256=iVJAOQ0viGTQOm0DLX4uZLro-9jOioYJGLg9s0kDx1A,78
133
133
  omdev/tools/doc.py,sha256=mv9XfitzqXl3vFHSenv01xHCxWf8g03rUAb_sqoty98,2556
@@ -143,9 +143,9 @@ omdev/tools/sqlrepl.py,sha256=tmFZh80-xsGM62dyQ7_UGLebChrj7IHbIPYBWDJMgVk,5741
143
143
  omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
144
144
  omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
145
145
  omdev/tools/pawk/pawk.py,sha256=Eckymn22GfychCQcQi96BFqRo_LmiJ-EPhC8TTUJdB4,11446
146
- omdev-0.0.0.dev120.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
147
- omdev-0.0.0.dev120.dist-info/METADATA,sha256=_EKIVacZqRgQDdQ5_usv_9GmkNdjXOGCSyGB5FssZyY,1810
148
- omdev-0.0.0.dev120.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
149
- omdev-0.0.0.dev120.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
150
- omdev-0.0.0.dev120.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
151
- omdev-0.0.0.dev120.dist-info/RECORD,,
146
+ omdev-0.0.0.dev122.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
147
+ omdev-0.0.0.dev122.dist-info/METADATA,sha256=0wbxz7KBMMCVnIglShq2u_mpBcUhPKpdxdkXRWbZ65A,1810
148
+ omdev-0.0.0.dev122.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
149
+ omdev-0.0.0.dev122.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
150
+ omdev-0.0.0.dev122.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
151
+ omdev-0.0.0.dev122.dist-info/RECORD,,