@@ -38,6 +38,10 @@ class PluginError(PythonLibCoreException):
38
38
pass
39
39
40
40
41
+ class NoKeywordFound (PythonLibCoreException ):
42
+ pass
43
+
44
+
41
45
class HybridCore :
42
46
def __init__ (self , library_components ):
43
47
self .keywords = {}
@@ -48,7 +52,7 @@ def __init__(self, library_components):
48
52
self .__set_library_listeners (library_components )
49
53
50
54
def add_library_components (self , library_components ):
51
- self .keywords_spec ["__init__" ] = KeywordBuilder .build (self .__init__ )
55
+ self .keywords_spec ["__init__" ] = KeywordBuilder .build (self .__init__ ) # type: ignore
52
56
for component in library_components :
53
57
for name , func in self .__get_members (component ):
54
58
if callable (func ) and hasattr (func , "robot_name" ):
@@ -123,6 +127,8 @@ def run_keyword(self, name, args, kwargs=None):
123
127
124
128
def get_keyword_arguments (self , name ):
125
129
spec = self .keywords_spec .get (name )
130
+ if not spec :
131
+ raise NoKeywordFound (f"Could not find keyword: { name } " )
126
132
return spec .argument_specification
127
133
128
134
def get_keyword_tags (self , name ):
@@ -132,6 +138,8 @@ def get_keyword_documentation(self, name):
132
138
if name == "__intro__" :
133
139
return inspect .getdoc (self ) or ""
134
140
spec = self .keywords_spec .get (name )
141
+ if not spec :
142
+ raise NoKeywordFound (f"Could not find keyword: { name } " )
135
143
return spec .documentation
136
144
137
145
def get_keyword_types (self , name ):
@@ -142,7 +150,7 @@ def get_keyword_types(self, name):
142
150
143
151
def __get_keyword (self , keyword_name ):
144
152
if keyword_name == "__init__" :
145
- return self .__init__
153
+ return self .__init__ # type: ignore
146
154
if keyword_name .startswith ("__" ) and keyword_name .endswith ("__" ):
147
155
return None
148
156
method = self .keywords .get (keyword_name )
@@ -234,11 +242,11 @@ def _get_kwargs(cls, arg_spec: inspect.FullArgSpec) -> list:
234
242
235
243
@classmethod
236
244
def _get_named_only_args (cls , arg_spec : inspect .FullArgSpec ) -> list :
237
- rf_spec = []
245
+ rf_spec : list = []
238
246
kw_only_args = arg_spec .kwonlyargs if arg_spec .kwonlyargs else []
239
247
if not arg_spec .varargs and kw_only_args :
240
248
rf_spec .append ("*" )
241
- kw_only_defaults = arg_spec .kwonlydefaults if arg_spec .kwonlydefaults else []
249
+ kw_only_defaults = arg_spec .kwonlydefaults if arg_spec .kwonlydefaults else {}
242
250
for kw_only_arg in kw_only_args :
243
251
if kw_only_arg in kw_only_defaults :
244
252
rf_spec .append ((kw_only_arg , kw_only_defaults [kw_only_arg ]))
@@ -320,7 +328,7 @@ def get_plugin_keywords(self, plugins: List):
320
328
return DynamicCore (plugins ).get_keyword_names ()
321
329
322
330
def _string_to_modules (self , modules ):
323
- parsed_modules = []
331
+ parsed_modules : list = []
324
332
if not modules :
325
333
return parsed_modules
326
334
for module in modules .split ("," ):
0 commit comments