This repository was archived by the owner on Nov 3, 2023. It is now read-only.
File tree 3 files changed +29
-4
lines changed 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 41
41
'console_scripts' : [
42
42
'pydocstyle = pydocstyle.cli:main' ,
43
43
],
44
+ 'pydocstyle_styles' : [
45
+ 'pydocstyle.base = pydocstyle.checkers.style.base' ,
46
+ 'pydocstyle.numpy = pydocstyle.checkers.style.numpy' ,
47
+ 'pydocstyle.other = pydocstyle.checkers.style.other' ,
48
+ ]
44
49
},
45
50
)
Original file line number Diff line number Diff line change 1
1
from pydocstyle .checkers .hooks import get_checkers
2
- # These imports below are required for registering the
3
- # checkers so that `get_checkers` captures them.
4
- from pydocstyle .checkers .style import numpy , base , other
5
2
6
- __all__ = ('get_checkers' , 'numpy' , 'base' , 'other' )
3
+ __all__ = ('get_checkers' ,)
Original file line number Diff line number Diff line change
1
+ import pkg_resources
2
+
3
+ from typing import Set
4
+
5
+ from pydocstyle .utils import log
6
+
1
7
__registered_checkers = []
8
+ __loaded_styles = set () # type: Set[str]
9
+
10
+ ENTRY_POINT_NAME = 'pydocstyle_styles'
11
+
2
12
3
13
def check_for (kind , terminal = False ):
4
14
def decorator (f ):
@@ -9,5 +19,18 @@ def decorator(f):
9
19
return decorator
10
20
11
21
22
+ def _load_styles ():
23
+ for entry_point in pkg_resources .iter_entry_points (ENTRY_POINT_NAME ):
24
+ if entry_point .name not in __loaded_styles :
25
+ try :
26
+ entry_point .load ()
27
+ except Exception as error :
28
+ log .exception ("Unable to load plugin %s.\n Error occurred: %s" ,
29
+ entry_point .name , error )
30
+ else :
31
+ __loaded_styles .add (entry_point .name )
32
+
33
+
12
34
def get_checkers ():
35
+ _load_styles ()
13
36
return iter (__registered_checkers )
You can’t perform that action at this time.
0 commit comments