Currently, configs are matched based on isinstance() checks. However, along with the changes discussed in #47, I want to make this system more flexible. My idea is to expect the object provided to Key to implement a is_match() method that accepts a instantiated config object and returns True/False indicating whether that config should be used with that key.
The default implementation would be provided by the base Config class, and would do the same isinstance() check that is currently done. But this would allow configs to customize how they are matched, and would allow users to provide custom rules for config-matching, for cases where the default rules don't work well (e.g. distinguishing between two configs of the same base class).
Currently, configs are matched based on
isinstance()
checks. However, along with the changes discussed in #47, I want to make this system more flexible. My idea is to expect the object provided toKey
to implement ais_match()
method that accepts a instantiated config object and returnsTrue
/False
indicating whether that config should be used with that key.The default implementation would be provided by the base
Config
class, and would do the sameisinstance()
check that is currently done. But this would allow configs to customize how they are matched, and would allow users to provide custom rules for config-matching, for cases where the default rules don't work well (e.g. distinguishing between two configs of the same base class).