ovld 0.5.1__py3-none-any.whl → 0.5.3__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.
ovld/codegen.py CHANGED
@@ -295,6 +295,7 @@ def codegen_specializer(typemap, fn, tup):
295
295
  adjusted_name = f"{fn.__name__.split('[')[0]}[{sigstring(tup)}]"
296
296
  func = rename_function(func, adjusted_name)
297
297
  func.__codegen__ = cg
298
+ func.__orig_name__ = fn.__name__
298
299
  return func
299
300
 
300
301
 
ovld/core.py CHANGED
@@ -169,7 +169,10 @@ class Ovld:
169
169
  else:
170
170
  hlp = ""
171
171
  for c in possibilities:
172
- hlp += f"* {c.handler.__name__} (priority: {c.priority}, specificity: {list(c.specificity)})\n"
172
+ hn = getattr(c.handler, "__orig_name__", c.handler.__name__)
173
+ hlp += (
174
+ f"* {hn} (priority: {c.priority}, specificity: {list(c.specificity)})\n"
175
+ )
173
176
  return ResolutionError(
174
177
  f"Ambiguous resolution in {self} for"
175
178
  f" argument types [{typenames}]\n"
ovld/medley.py CHANGED
@@ -178,7 +178,9 @@ class medley_cls_dict(dict):
178
178
 
179
179
  combiner = self._combiners.get(attr, None)
180
180
  if combiner is None:
181
- if inspect.isfunction(value) or isinstance(value, Ovld):
181
+ if to_ovld(value, force=False):
182
+ combiner = BuildOvld(attr)
183
+ elif inspect.isfunction(value):
182
184
  combiner = self._default_combiner(attr)
183
185
  else:
184
186
  combiner = KeepLast(attr)
ovld/mro.py CHANGED
@@ -137,7 +137,7 @@ def subclasscheck(t1, t2):
137
137
  if o1 or o2:
138
138
  o1 = o1 or t1
139
139
  o2 = o2 or t2
140
- if issubclass(o1, o2):
140
+ if isinstance(o1, type) and isinstance(o2, type) and issubclass(o1, o2):
141
141
  if o2 is t2: # pragma: no cover
142
142
  return True
143
143
  else:
ovld/recode.py CHANGED
@@ -496,7 +496,18 @@ def recode(fn, ovld, syms, newname):
496
496
  if fn.__closure__:
497
497
  new = closure_wrap(new.body[0], "irrelevant", fn.__code__.co_freevars)
498
498
  ast.fix_missing_locations(new)
499
- ast.increment_lineno(new, fn.__code__.co_firstlineno - 1)
499
+ line_delta = fn.__code__.co_firstlineno - 1
500
+ col_delta = len(firstline := src.split("\n", 1)[0]) - len(firstline.lstrip())
501
+ for node in ast.walk(new):
502
+ if hasattr(node, "lineno"):
503
+ node.lineno += line_delta
504
+ if hasattr(node, "end_lineno"):
505
+ node.end_lineno += line_delta
506
+ if hasattr(node, "col_offset"):
507
+ node.col_offset += col_delta
508
+ if hasattr(node, "end_col_offset"):
509
+ node.end_col_offset += col_delta
510
+
500
511
  res = compile(new, mode="exec", filename=fn.__code__.co_filename)
501
512
  if fn.__closure__:
502
513
  res = [x for x in res.co_consts if isinstance(x, CodeType)][0]
ovld/utils.py CHANGED
@@ -106,7 +106,7 @@ def clsstring(cls):
106
106
  return f"{origin.__name__}[{args}]"
107
107
  else:
108
108
  r = repr(cls)
109
- if r.startswith("<class "):
109
+ if r.startswith("<class ") or r.startswith("<enum "):
110
110
  return cls.__name__
111
111
  else:
112
112
  return r
@@ -160,7 +160,7 @@ class NameDatabase:
160
160
  return name
161
161
 
162
162
  def get(self, value, suggested_name=None):
163
- if isinstance(value, (int, float, str)):
163
+ if type(value) in (int, float, str):
164
164
  return repr(value)
165
165
  if id(value) in self.names:
166
166
  return self.names[id(value)]
ovld/version.py CHANGED
@@ -1 +1 @@
1
- version = "0.5.1"
1
+ version = "0.5.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ovld
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: Overloading Python functions
5
5
  Project-URL: Homepage, https://ovld.readthedocs.io/en/latest/
6
6
  Project-URL: Documentation, https://ovld.readthedocs.io/en/latest/
@@ -0,0 +1,18 @@
1
+ ovld/__init__.py,sha256=JuCM8Sj65gobV0KYyLr95cSI23Pi6RYZ7X3_F3fdsSw,1821
2
+ ovld/abc.py,sha256=4qpZyYwI8dWgY1Oiv5FhdKg2uzNcyWxIpGmGJVcjXrs,1177
3
+ ovld/codegen.py,sha256=N8qgnpitPD8HEzNWQqmPw4MmSs3wdMsW9qoMo1jEhps,9247
4
+ ovld/core.py,sha256=HEREHblKcjM9dhFBr0FNwUCyec7o-9XjCsCfJ23SnNw,17544
5
+ ovld/dependent.py,sha256=h3j4oQYTQfGqMzggWlLV6TpojX_GtYRFWAO0GcMB0Zs,9085
6
+ ovld/medley.py,sha256=0fseIntzJRCPYXq-tmnxgy5ipNa4ZxR0D_6So0xstdQ,12729
7
+ ovld/mro.py,sha256=LXHkP_28J9EwM9IrXYraYI0qm4dHWkDKCgkXn0u_YCo,4655
8
+ ovld/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ ovld/recode.py,sha256=ZVqD3sCu_myaFj3lKPCMjFBf1pTdTAAd3NJdsqtLYuU,16434
10
+ ovld/signatures.py,sha256=Q8JucSOun0ESGx14aWtHtBzLEiM6FxY5HP3imyqXoDo,8984
11
+ ovld/typemap.py,sha256=5Pro1Ee60fH4L7NW7k5nbN5EfDygA0LFHcI6o3mCagI,13596
12
+ ovld/types.py,sha256=0hkhAR5_5793NABdrM-fP1dSJBhYof85FILKqVP2YMg,13392
13
+ ovld/utils.py,sha256=MAPQUhZc3_AcLrU4jFQrkVu4nvMJJKiw10N7zFk5QPc,4294
14
+ ovld/version.py,sha256=9iBSpgY-F4wj0t-upZDlLaji0_l-xTEqXo5_nwN8O1M,18
15
+ ovld-0.5.3.dist-info/METADATA,sha256=2l6SNs5EFY56D3EvhxubpQ-mXoz21EUPLqcFb3JUeVg,9276
16
+ ovld-0.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
+ ovld-0.5.3.dist-info/licenses/LICENSE,sha256=cSwNTIzd1cbI89xt3PeZZYJP2y3j8Zus4bXgo4svpX8,1066
18
+ ovld-0.5.3.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- ovld/__init__.py,sha256=JuCM8Sj65gobV0KYyLr95cSI23Pi6RYZ7X3_F3fdsSw,1821
2
- ovld/abc.py,sha256=4qpZyYwI8dWgY1Oiv5FhdKg2uzNcyWxIpGmGJVcjXrs,1177
3
- ovld/codegen.py,sha256=oHfQHlVJUB1Y0PO--rhhkfAmgOhIhKNZyBcodrS1GEs,9210
4
- ovld/core.py,sha256=bnp2LIVBUCvNhI53csWaAs7hlxinOBOXhPeoAw_GD3s,17443
5
- ovld/dependent.py,sha256=h3j4oQYTQfGqMzggWlLV6TpojX_GtYRFWAO0GcMB0Zs,9085
6
- ovld/medley.py,sha256=bp4e-6qH5_Qq05poPu7AcuWf-0mqNCqKMrdK44K2hSs,12667
7
- ovld/mro.py,sha256=nqe9jHvsaLu-CfXoP2f7tHg5_8IkcESWMnBmvr4XGIo,4605
8
- ovld/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- ovld/recode.py,sha256=YrftCClBcP_luOdqeeQ_EQJddRjikLpY5RmYGRCQrOs,16008
10
- ovld/signatures.py,sha256=Q8JucSOun0ESGx14aWtHtBzLEiM6FxY5HP3imyqXoDo,8984
11
- ovld/typemap.py,sha256=5Pro1Ee60fH4L7NW7k5nbN5EfDygA0LFHcI6o3mCagI,13596
12
- ovld/types.py,sha256=0hkhAR5_5793NABdrM-fP1dSJBhYof85FILKqVP2YMg,13392
13
- ovld/utils.py,sha256=wO9IQqPVkcS1Opd8cl79WMMpWdCbMQY66PuWF2hMkvc,4272
14
- ovld/version.py,sha256=-u_JHy_NHod_JgjQcxN3CYo6TWCz6XQgbb-Z1FmF2Fg,18
15
- ovld-0.5.1.dist-info/METADATA,sha256=Lp8FkGbpbaMftXuCYLX3yeCdNTjV67U4ov0h9GV7tCI,9276
16
- ovld-0.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- ovld-0.5.1.dist-info/licenses/LICENSE,sha256=cSwNTIzd1cbI89xt3PeZZYJP2y3j8Zus4bXgo4svpX8,1066
18
- ovld-0.5.1.dist-info/RECORD,,
File without changes