configuration_mixin.py 1.1 KB

1234567891011121314151617181920212223242526
  1. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  2. # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
  3. from pylint.config.option_manager_mixin import OptionsManagerMixIn
  4. from pylint.config.options_provider_mixin import OptionsProviderMixIn
  5. class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn):
  6. """basic mixin for simple configurations which don't need the
  7. manager / providers model"""
  8. def __init__(self, *args, **kwargs):
  9. if not args:
  10. kwargs.setdefault("usage", "")
  11. OptionsManagerMixIn.__init__(self, *args, **kwargs)
  12. OptionsProviderMixIn.__init__(self)
  13. if not getattr(self, "option_groups", None):
  14. self.option_groups = []
  15. for _, optdict in self.options:
  16. try:
  17. gdef = (optdict["group"].upper(), "")
  18. except KeyError:
  19. continue
  20. if gdef not in self.option_groups:
  21. self.option_groups.append(gdef)
  22. self.register_options_provider(self, own_group=False)