One function

get_origin in ramonhagenaars/typish

The author described this change as Fix for get origin with types that shadow typing types.. It counts as a record because the check below fails on the code as it stood at 0e2ceaf82 and passes on 890577808, with nothing else changed between the two runs.

Fix saved2020-10-07
Sharing licenceMIT · LICENSE
Change size+3 1

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

Return the origin of the given (generic) type. For example, for `t=List[str]`, the result would be `list`. :param t: the type of which the origin is to be found. :return: the origin of `t` or `t` if it is not generic.

The change

99
1010 simple_name = get_simple_name(t)
1111 result = _type_per_alias.get(simple_name, None)
12- if not result:
12+ if isclass(t) and not is_from_typing(t):
13+ result = t
14+ elif not result:
1315 result = getattr(typing, simple_name, t)
1416 return result

The check that tells the two apart

failpass·tests/functions/test_origin_and_alias.py::TestOriginAndAlias::test_get_origin

Check file tests/functions/test_origin_and_alias.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 it0e2ceaf8267a235ba491eae6ffbebec4209ae6a7
Broken version dated2020-10-06
Moduletypish.functions._get_origin
Units changedget_origin
Fingerprint1bc3d117047b3cae
Checked2026-08-18 by goldset/0.1

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

Other bugs found in ramonhagenaars/typish