plugin.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """Common Django module."""
  2. from pylint.checkers.base import NameChecker
  3. from pylint_plugin_utils import get_checker
  4. # we want to import the transforms to make sure they get added to the astroid manager,
  5. # however we don't actually access them directly, so we'll disable the warning
  6. from pylint_django import transforms # noqa, pylint: disable=unused-import
  7. from pylint_django import compat
  8. from pylint_django.checkers import register_checkers
  9. def load_configuration(linter):
  10. """
  11. Amend existing checker config.
  12. """
  13. name_checker = get_checker(linter, NameChecker)
  14. name_checker.config.good_names += (
  15. "qs",
  16. "urlpatterns",
  17. "register",
  18. "app_name",
  19. "handler400",
  20. "handler403",
  21. "handler404",
  22. "handler500",
  23. )
  24. # we don't care about South migrations
  25. linter.config.black_list += ("migrations", "south_migrations")
  26. def register(linter):
  27. """
  28. Registering additional checkers.
  29. """
  30. # add all of the checkers
  31. register_checkers(linter)
  32. # register any checking fiddlers
  33. try:
  34. # pylint: disable=import-outside-toplevel
  35. from pylint_django.augmentations import apply_augmentations
  36. apply_augmentations(linter)
  37. except ImportError:
  38. # probably trying to execute pylint_django when Django isn't installed
  39. # in this case the django-not-installed checker will kick-in
  40. pass
  41. if not compat.LOAD_CONFIGURATION_SUPPORTED:
  42. load_configuration(linter)