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.
Projectbreuleux/ovld
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
| 56 | 56 | results = {} | |
| 57 | 57 | if is_type_of_type(obj_t): | |
| 58 | 58 | mro = [type[t] for t in compose_mro(obj_t.__args__[0], self.types)] | |
| 59 | + | mro.append(type) | |
| 60 | + | mro.append(object) | |
| 59 | 61 | else: | |
| 60 | 62 | mro = compose_mro(obj_t, self.types) | |
| 61 | 63 | for lvl, cls in enumerate(reversed(mro)): | |
| ⋯ | |||
| 95 | 97 | self.key_error = key_error | |
| 96 | 98 | ||
| 97 | 99 | def transform(self, obj): | |
| 98 | - | if isinstance(obj, type): | |
| 99 | - | return type[obj] | |
| 100 | - | elif isinstance(obj, GenericAlias): | |
| 100 | + | if isinstance(obj, GenericAlias): | |
| 101 | 101 | return type[obj.__origin__] | |
| 102 | + | elif isinstance(obj, type): | |
| 103 | + | return type[obj] | |
| 102 | 104 | else: | |
| 103 | 105 | return type(obj) | |
| 104 | 106 | ||
The check that tells the two apart
fail→pass·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.