Closed maxzhenzhera closed 1 year ago
For now, the support of generics is not guaranteed.
typing.Generic do caching. But cache size is limited. When new instances of GenericAlias are being created - the current hook in bind_by_type does not handle this case because it does the is check. https://github.com/adriangb/di/blob/e88c8f9f1e6ddd06d41095025ea209f6f8d15056/di/_container.py#L81-L98
typing.Generic
GenericAlias
bind_by_type
is
I propose to do a == check. It is completely safe for simple types ([default __eq__ is actualy is](https://docs.python.org/3/reference/datamodel.html?highlight=By%20default,%20object%20implements%20__eq__()%20by%20using%20is#object.__eq__)). But also this will handle GenericAlias __eq__.
==
__eq__
For now, the support of generics is not guaranteed.
typing.Generic
do caching. But cache size is limited. When new instances ofGenericAlias
are being created - the current hook inbind_by_type
does not handle this case because it does theis
check. https://github.com/adriangb/di/blob/e88c8f9f1e6ddd06d41095025ea209f6f8d15056/di/_container.py#L81-L98I propose to do a
==
check. It is completely safe for simple types ([default__eq__
is actualyis
](https://docs.python.org/3/reference/datamodel.html?highlight=By%20default,%20object%20implements%20__eq__()%20by%20using%20is#object.__eq__)). But also this will handle GenericAlias__eq__
.