Registry types inconsistency
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.
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?