| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…ble` and custom generics with `ParamSpec`
|
I encountered another bug, the __repr__ needs to be updated as well: >>> ca.Callable[[int, P], int][P][int] collections.abc.Callable[[int, (<class 'int'>,)], int] EDIT: THIS MIGHT NOT BE A BUG, AS ITS AN INVALID USE. PLEASE IGNORE THIS @sobolevn |
Sorry, something went wrong.
|
@Fidget-Spinner I would like to move all repr related problems to another PR if that possible :) I've only touched params substitution here. |
Sorry, something went wrong.
|
Wait a moment, this is not about repr, this is an __args__ containing a tuple 😒 >>> ca.Callable[[int, P], int][P].__args__
(<class 'int'>, ~P, <class 'int'>)
>>> ca.Callable[[int, P], int][P][int].__args__
(<class 'int'>, (<class 'int'>,), <class 'int'>) |
Sorry, something went wrong.
|
Funny thing, I just removed this code from _collections_abc.py as an experiment: if (len(self.__parameters__) == 1
and _is_param_expr(self.__parameters__[0])
and item and not _is_param_expr(item[0])):
item = (item,)All tests still pass :) 🤯 |
Sorry, something went wrong.
There was a problem hiding this comment.
I think the runtime is correct in raising TypeError for these situations, actually: see #102615 (comment)
Maybe instead, we should focus on improving the error message, so that users get more specific feedback on why the substitution is being disallowed? Though if it adds too much complexity to the code, I probably wouldn't bother with it.
Sorry, something went wrong.
|
I am going to close this for now, I will add new tests in other PRs, because this one has a big unrelated history. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I would prefer to create two PRs to fix #102615