@@ -38,6 +38,10 @@ class PluginError(PythonLibCoreException):
3838 pass
3939
4040
41+ class NoKeywordFound (PythonLibCoreException ):
42+ pass
43+
44+
4145class HybridCore :
4246 def __init__ (self , library_components ):
4347 self .keywords = {}
@@ -48,7 +52,7 @@ def __init__(self, library_components):
4852 self .__set_library_listeners (library_components )
4953
5054 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
5256 for component in library_components :
5357 for name , func in self .__get_members (component ):
5458 if callable (func ) and hasattr (func , "robot_name" ):
@@ -123,6 +127,8 @@ def run_keyword(self, name, args, kwargs=None):
123127
124128 def get_keyword_arguments (self , name ):
125129 spec = self .keywords_spec .get (name )
130+ if not spec :
131+ raise NoKeywordFound (f"Could not find keyword: { name } " )
126132 return spec .argument_specification
127133
128134 def get_keyword_tags (self , name ):
@@ -132,6 +138,8 @@ def get_keyword_documentation(self, name):
132138 if name == "__intro__" :
133139 return inspect .getdoc (self ) or ""
134140 spec = self .keywords_spec .get (name )
141+ if not spec :
142+ raise NoKeywordFound (f"Could not find keyword: { name } " )
135143 return spec .documentation
136144
137145 def get_keyword_types (self , name ):
@@ -142,7 +150,7 @@ def get_keyword_types(self, name):
142150
143151 def __get_keyword (self , keyword_name ):
144152 if keyword_name == "__init__" :
145- return self .__init__
153+ return self .__init__ # type: ignore
146154 if keyword_name .startswith ("__" ) and keyword_name .endswith ("__" ):
147155 return None
148156 method = self .keywords .get (keyword_name )
@@ -234,11 +242,11 @@ def _get_kwargs(cls, arg_spec: inspect.FullArgSpec) -> list:
234242
235243 @classmethod
236244 def _get_named_only_args (cls , arg_spec : inspect .FullArgSpec ) -> list :
237- rf_spec = []
245+ rf_spec : list = []
238246 kw_only_args = arg_spec .kwonlyargs if arg_spec .kwonlyargs else []
239247 if not arg_spec .varargs and kw_only_args :
240248 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 {}
242250 for kw_only_arg in kw_only_args :
243251 if kw_only_arg in kw_only_defaults :
244252 rf_spec .append ((kw_only_arg , kw_only_defaults [kw_only_arg ]))
@@ -320,7 +328,7 @@ def get_plugin_keywords(self, plugins: List):
320328 return DynamicCore (plugins ).get_keyword_names ()
321329
322330 def _string_to_modules (self , modules ):
323- parsed_modules = []
331+ parsed_modules : list = []
324332 if not modules :
325333 return parsed_modules
326334 for module in modules .split ("," ):
0 commit comments