Whole file

breuleux/ovld

The author described this change as Fix resolution for type arguments with plain `type` annotation. It counts as a record because the check below fails on the code as it stood at 641b15fdd and passes on 494001155, with nothing else changed between the two runs.

Fix saved2024-04-12
Sharing licenceMIT · LICENSE
Change size+5 3

What the code was meant to do, written into the code itself as a save note

Fix resolution for type arguments with plain `type` annotation

The change

5656 results = {}
5757 if is_type_of_type(obj_t):
5858 mro = [type[t] for t in compose_mro(obj_t.__args__[0], self.types)]
59+ mro.append(type)
60+ mro.append(object)
5961 else:
6062 mro = compose_mro(obj_t, self.types)
6163 for lvl, cls in enumerate(reversed(mro)):
9597 self.key_error = key_error
9698
9799 def transform(self, obj):
98- if isinstance(obj, type):
99- return type[obj]
100- elif isinstance(obj, GenericAlias):
100+ if isinstance(obj, GenericAlias):
101101 return type[obj.__origin__]
102+ elif isinstance(obj, type):
103+ return type[obj]
102104 else:
103105 return type(obj)
104106

The check that tells the two apart

failpass·tests/test_ovld.py::test_plain_type_argument

Check file tests/test_ovld.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it641b15fdd2ed6f5ed667078096a53b5b89c24098
Broken version dated2024-04-12
Moduleovld.core
Units changedMultiTypeMap, TypeMap
Fingerprintdb7318916c048c0d
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.