client_python icon indicating copy to clipboard operation
client_python copied to clipboard

Registry types inconsistency

Open decaz opened this issue 3 years ago • 1 comments

Encoder generate_latest (for example) accepts registry of CollectorRegistry type but it doesn't accept registry of RestrictedRegistry type so it is not consistent. I guess RestrictedRegistry class should inherit CollectorRegistry class because instance of it can be passed to encoders (maybe not only encoders).

Another option is to inherit RestrictedRegistry class from Collector class because CollectorRegistry is inherited from this class, but then anything that accepts CollectorRegistry type should be changed to accept Collector type.

decaz avatar Jul 22 '22 16:07 decaz

Yes, we should improve the type consistency here. Probably everything should be changed to the Collector type, which would ideally be a Protocol rather than enforcing inheritance. The problem with using a Protocol is that older versions of python would need to depend on typing-extensions and this client currently has no dependencies. Perhaps typing-extensions is widespread enough that would be ok though?

csmarchbanks avatar Jul 26 '22 20:07 csmarchbanks