09.09.21 17:19, Randolf Scholz пише: > As a sidenote, I think it would actually be kinda cool to have the > `typing.Any` behave this way, i.e. always comparing to True. > One example where this would be useful is that it would allow comparisons like > > ```python > assert mytuple == (Any, "abc") > ``` > > which would then be equivalent, but imo a lot more elegant than > > ```python > assert len(mytuple) == 2 and mytuple[-1] == "abc" > ```
Did you try to use unittest.mock.ANY? typing.Any cannot behave this way. First, list[Any] and list[int] are different types. Second, an object which is equal to everything cannot be hashable, but typing.Any is hashable, and should be hashable for using in caching. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/NKNEBHALK43NKBX3N5EYN56RKC2PBOK2/ Code of Conduct: http://python.org/psf/codeofconduct/