Skip to content

Commit

Permalink
fix: make plugin module more robust and make yamllint works even if s…
Browse files Browse the repository at this point in the history
…etuptools was not installed
  • Loading branch information
ssato committed Sep 9, 2020
1 parent fc9d81b commit 9cf8903
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ include_package_data = True
install_requires =
pathspec >= 0.5.3
pyyaml
setuptools

test_suite = tests

Expand Down
11 changes: 8 additions & 3 deletions yamllint/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
Plugin module utilizing setuptools (pkg_resources) to allow users to add their
own custom lint rules.
"""
import pkg_resources
try:
from pkg_resources import iter_entry_points
except ImportError:
def iter_entry_points(group):
"""Dummy function for pkg_resources.iter_entry_points."""
yield


PACKAGE_GROUP = "yamllint.plugins"
Expand All @@ -32,11 +37,11 @@ def validate_rule_module(rule_mod):

def load_plugin_rules_itr(group=PACKAGE_GROUP):
"""Load custom lint rule plugins."""
for entry in pkg_resources.iter_entry_points(group):
for entry in iter_entry_points(group):
try:
rules_mod = entry.load()
yield rules_mod.RULES_MAP
except ImportError:
except AttributeError:
pass # TBD


Expand Down

0 comments on commit 9cf8903

Please sign in to comment.