The following changes only impact you if your code defines its own class registry subclasses. If you do not subclass any of the class registry classes (e.g., if you're not doing class MyClassRegistry(ClassRegistry): anywhere in your code), you do not have to do anything.
Renamed class_registry.MutableRegistry to class_registry.BaseMutableRegistry.
If you are subclassing MutableRegistry in your code, change the base class to BaseMutableRegistry instead.
If you are not subclassing MutableRegistry, you don't have to do anything.
When a class registry overrides gen_lookup_keys, the __iter__, items, and keys methods iterate over the human-readable keys, not the lookup keys.
Contrived example: if a subclass overrides gen_lookup_key to return a hash of the key:
Previous version: The hashed keys would be included in the output from items, etc.
This version: The original un-hashed keys would be included instead.
See test.registry_test.GenLookupKeyTestCase for more information and examples.
If your code subclasses any of the class registry classes and it overrides the gen_lookup_key method, you may
need to update any code that iterates over keys/items in that registry.
If you are not overriding the gen_lookup_key method, you do not have to do anything.
SortedClassRegistry now provides both the human-readable key and the lookup key to sorting functions.
Contrived example: if a subclass overrides gen_lookup_key to return a hash of the key:
Previous version: The hashed keys would be used for sorting.
This version: The original un-hashed keys would be used instead.
See test.registry_test.SortedClassRegistryTestCase.test_gen_lookup_key_overridden for more information.
If your code subclasses SortedClassRegistry and overrides the gen_lookup_key method, you may need to update the sorting function, as the arguments that get passed to it will have a slightly different structure (refer to the test referenced above to see an example).
If you are not overriding the gen_lookup_key method, you do not have to do anything.
Changed type hint for items, keys, and values methods; these should now return a generator rather than an iterable.
This shouldn't break existing code, but if you have code that overrides these methods, you may want to update them to prevent potential (but unlikely 😇) issues in future versions of phx-class-registry.
If you are not overriding any of these methods, you do not have to do anything.
Changelog
Switched official support to Python 3.11, 3.10, and 3.9 (but older versions are supported unofficially).
Fixed incorrect documentation for the unique parameter for ClassRegistry.__init__ (thanks @adrian-nilsson-fcc!).
Added test coverage for overridden gen_lookup_key.
Added documentation for overriding gen_lookup_key in subclasses.
Added missing type hints and fixed some incorrect type hints.
⚠️ Backwards-Incompatible Changes
The following changes only impact you if your code defines its own class registry subclasses. If you do not subclass any of the class registry classes (e.g., if you're not doing
class MyClassRegistry(ClassRegistry):
anywhere in your code), you do not have to do anything.class_registry.MutableRegistry
toclass_registry.BaseMutableRegistry
.MutableRegistry
in your code, change the base class toBaseMutableRegistry
instead.MutableRegistry
, you don't have to do anything.gen_lookup_keys
, the__iter__
,items
, andkeys
methods iterate over the human-readable keys, not the lookup keys.gen_lookup_key
to return a hash of the key:items
, etc.test.registry_test.GenLookupKeyTestCase
for more information and examples.gen_lookup_key
method, you may need to update any code that iterates over keys/items in that registry.gen_lookup_key
method, you do not have to do anything.SortedClassRegistry
now provides both the human-readable key and the lookup key to sorting functions.gen_lookup_key
to return a hash of the key:test.registry_test.SortedClassRegistryTestCase.test_gen_lookup_key_overridden
for more information.SortedClassRegistry
and overrides thegen_lookup_key
method, you may need to update the sorting function, as the arguments that get passed to it will have a slightly different structure (refer to the test referenced above to see an example).gen_lookup_key
method, you do not have to do anything.items
,keys
, andvalues
methods; these should now return a generator rather than an iterable.phx-class-registry
.Changelog
unique
parameter forClassRegistry.__init__
(thanks @adrian-nilsson-fcc!).gen_lookup_key
.gen_lookup_key
in subclasses.