kalekundert / byoc

MIT License
0 stars 0 forks source link

Allow configs to control how they are matched #48

Closed kalekundert closed 1 year ago

kalekundert commented 1 year ago

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).