diff options
Diffstat (limited to 'python/helpers/pycharm_generator_utils/util_methods.py')
-rw-r--r-- | python/helpers/pycharm_generator_utils/util_methods.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/python/helpers/pycharm_generator_utils/util_methods.py b/python/helpers/pycharm_generator_utils/util_methods.py index d679e3385264..b6805c4a5942 100644 --- a/python/helpers/pycharm_generator_utils/util_methods.py +++ b/python/helpers/pycharm_generator_utils/util_methods.py @@ -75,6 +75,47 @@ class __generator(object): """ return txt +def create_function(): + txt = """ +class __function(object): + '''A mock class representing function type.''' + + def __init__(self): + self.__name__ = '' + self.__doc__ = '' + self.__dict__ = '' + self.__module__ = '' +""" + if version[0] == 2: + txt += """ + self.func_defaults = {} + self.func_globals = {} + self.func_closure = None + self.func_code = None + self.func_name = '' + self.func_doc = '' + self.func_dict = '' +""" + if version[0] >= 3 or (version[0] == 2 and version[1] >= 6): + txt += """ + self.__defaults__ = {} + self.__globals__ = {} + self.__closure__ = None + self.__code__ = None + self.__name__ = '' +""" + if version[0] >= 3: + txt += """ + self.__annotations__ = {} + self.__kwdefaults__ = {} +""" + if version[0] >= 3 and version[1] >= 3: + txt += """ + self.__qualname__ = '' +""" + return txt + + def _searchbases(cls, accum): # logic copied from inspect.py if cls not in accum: |