| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| For a typing object of the form ``X[Y, Z, ...]`` these functions return | ||
| ``X`` and ``(Y, Z, ...)``. If ``X`` is a generic alias for a builtin or | ||
| :mod:`collections` class, it gets normalized to the original class. | ||
| If ``X`` is a :class:`Union`, the order of ``(Y, Z, ...)`` may be different |
There was a problem hiding this comment.
| If ``X`` is a :class:`Union`, the order of ``(Y, Z, ...)`` may be different | |
| If ``X`` is a :class:`Union` contained in another generic type, the order of ``(Y, Z, ...)`` may be different |
Sorry, something went wrong.
|
I don't really like the current proposed change because it's too broad, it may cause users to worry that all nested types are affected, when in reality it's only Union. Instead of:
Guido's change seems a lot more apt:
A quick search through the typing code tells me that only the __hash__ and __eq__ methods of Union are order independent, no other typing type will suffer from this behavior when nested in another Generic. |
Sorry, something went wrong.
It's as broad as the promise of type caching goes, so I don't think it's too broad. But I agree that it's broader than necessary since indeed, at the moment, it requires a Union to be involved. Initially I thought it would also affect Literal, but apparently it doesn't: >>> Literal[1, 2] == Literal[2, 1] False (Though I don't see why the two would be unequal; but that's a different concern)
So I just revert back to Guido's version? |
Sorry, something went wrong.
Wow good catch, that looks like it may be a bug.
Maybe a combination of both yours and Guido's wording: If `X` is a :class:`Union` contained in another generic type, the order of `(Y, Z, ...)` may be different due to type caching. Btw, thank you for the PR! |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks, LG!
Sorry, something went wrong.
|
Thanks @Dominik1123 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Sorry, something went wrong.
|
GH-23307 is a backport of this pull request to the 3.9 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
https://bugs.python.org/issue42317
Automerge-Triggered-By: GH:gvanrossum