From d768a43280ae27d498603d155a63b9f5c07e4994 Mon Sep 17 00:00:00 2001 From: Aryabhatta Dey Date: Mon, 13 May 2024 09:36:01 +0530 Subject: [PATCH 1/5] Fix SyntaxError: invalid syntax in doc/fill_gpi.py --- doc/fill_gpi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fill_gpi.py b/doc/fill_gpi.py index 500316ddda..12d7054b9e 100755 --- a/doc/fill_gpi.py +++ b/doc/fill_gpi.py @@ -66,7 +66,7 @@ def signature(func, name=None): Returns: a string representing its signature as would be written in code """ - args, varargs, varkw, defaults = inspect.getargspec(func) + args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations = inspect.getfullargspec(func) defaults = defaults or [] # If there are no defaults, set it to an empty list defaults = [repr(d) for d in defaults] # Type to get a useful string representing the default From 90a9e35a8d1bf786f2fc66a117a407484ec8c45d Mon Sep 17 00:00:00 2001 From: Aryabhatta Dey Date: Wed, 22 May 2024 09:21:27 +0530 Subject: [PATCH 2/5] Use _ to mark the new unused variables from the return value of getfullargspec instead of explicity naming them. --- doc/fill_gpi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fill_gpi.py b/doc/fill_gpi.py index 12d7054b9e..b47bc3a16f 100755 --- a/doc/fill_gpi.py +++ b/doc/fill_gpi.py @@ -66,7 +66,7 @@ def signature(func, name=None): Returns: a string representing its signature as would be written in code """ - args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations = inspect.getfullargspec(func) + args, varargs, varkw, defaults, *_ = inspect.getfullargspec(func) defaults = defaults or [] # If there are no defaults, set it to an empty list defaults = [repr(d) for d in defaults] # Type to get a useful string representing the default From 5dca2372b15df2739d49174045b616db30901b9d Mon Sep 17 00:00:00 2001 From: aryabhatta-dey Date: Wed, 22 May 2024 05:40:20 +0000 Subject: [PATCH 3/5] autopep8 action fixes --- doc/fill_gpi.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/doc/fill_gpi.py b/doc/fill_gpi.py index 500316ddda..d7c962206a 100755 --- a/doc/fill_gpi.py +++ b/doc/fill_gpi.py @@ -46,7 +46,7 @@ def indent(s, depth=''): """ Adds `indent` to the beginning of every line """ - return '\n'.join(depth+l for l in s.splitlines()) + return '\n'.join(depth + l for l in s.splitlines()) def reindent(docstring, depth=''): @@ -81,23 +81,29 @@ def signature(func, name=None): for arg, default in arg_pairs: full_arg = arg if default is not None: - full_arg += '='+default + full_arg += '=' + default arg_strings.append(full_arg) # and append args and kwargs if necessary to get # arg_strings=['a', 'b', 'a=None', 'd=4', '*args', '**kwargs'] if varargs is not None: - arg_strings.append('*'+varargs) + arg_strings.append('*' + varargs) if varkw is not None: - arg_strings.append('**'+varkw) + arg_strings.append('**' + varkw) # Signature is then 'foo(a, b, c=None, d=4, *args, **kwargs)' return '{name}({args})'.format(name=name or func.__name__, args=', '.join(arg_strings)) # First we get all objects that are in Ganga.GPI and filter out any non-GangaObjects -gpi_classes = [stripProxy(o) for name, o in GangaCore.GPI.__dict__.items() if isinstance(o, type) and issubclass(o, GPIProxyObject)] +gpi_classes = [ + stripProxy(o) for name, + o in GangaCore.GPI.__dict__.items() if isinstance( + o, + type) and issubclass( + o, + GPIProxyObject)] -with open(doc_dir+'/GPI/classes.rst', 'w') as cf: +with open(doc_dir + '/GPI/classes.rst', 'w') as cf: print('GPI classes', file=cf) print('===========', file=cf) @@ -151,7 +157,7 @@ def signature(func, name=None): # Looking through the plugin list helps categorise the GPI objects -with open(doc_dir+'/GPI/plugins.rst', 'w') as pf: +with open(doc_dir + '/GPI/plugins.rst', 'w') as pf: from GangaCore.Utility.Plugin.GangaPlugin import allPlugins print('Plugins', file=pf) @@ -160,7 +166,7 @@ def signature(func, name=None): for c, ps in allPlugins.allCategories().items(): print(c, file=pf) - print('-'*len(c), file=pf) + print('-' * len(c), file=pf) print('', file=pf) for name, c in ps.items(): @@ -172,7 +178,8 @@ def signature(func, name=None): print('') # All objects that are not proxied GangaObjects -gpi_objects = dict((name, stripProxy(o)) for name, o in GangaCore.GPI.__dict__.items() if stripProxy(o) not in gpi_classes and not name.startswith('__')) +gpi_objects = dict((name, stripProxy(o)) for name, o in GangaCore.GPI.__dict__.items() + if stripProxy(o) not in gpi_classes and not name.startswith('__')) # Any objects which are not exposed as proxies (mostly exceptions) non_proxy_classes = dict((k, v) for k, v in gpi_objects.items() if inspect.isclass(v)) @@ -183,7 +190,7 @@ def signature(func, name=None): # Things which were declared as actual functions functions = dict((k, v) for k, v in callables.items() if inspect.isfunction(v) or inspect.ismethod(v)) -with open(doc_dir+'/GPI/functions.rst', 'w') as ff: +with open(doc_dir + '/GPI/functions.rst', 'w') as ff: print('Functions', file=ff) print('=========', file=ff) From 3ea18927cf940793b8714e36c699b2380738f0e7 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 22 May 2024 12:49:25 +0100 Subject: [PATCH 4/5] Update fill_gpi.py --- doc/fill_gpi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fill_gpi.py b/doc/fill_gpi.py index d7c962206a..b4f624978b 100755 --- a/doc/fill_gpi.py +++ b/doc/fill_gpi.py @@ -46,7 +46,7 @@ def indent(s, depth=''): """ Adds `indent` to the beginning of every line """ - return '\n'.join(depth + l for l in s.splitlines()) + return '\n'.join(depth + _l for _l in s.splitlines()) def reindent(docstring, depth=''): From b793281fb8a3d81f0ee93b1487419141a0ad8058 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Wed, 22 May 2024 18:29:48 +0100 Subject: [PATCH 5/5] Update fill_gpi.py --- doc/fill_gpi.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/fill_gpi.py b/doc/fill_gpi.py index f702d01add..fde9d450ff 100755 --- a/doc/fill_gpi.py +++ b/doc/fill_gpi.py @@ -96,12 +96,9 @@ def signature(func, name=None): # First we get all objects that are in Ganga.GPI and filter out any non-GangaObjects gpi_classes = [ - stripProxy(o) for name, - o in GangaCore.GPI.__dict__.items() if isinstance( - o, - type) and issubclass( - o, - GPIProxyObject)] + stripProxy(o) for name, o in GangaCore.GPI.__dict__.items() + if isinstance(o, type) and issubclass(o, GPIProxyObject) +] with open(doc_dir + '/GPI/classes.rst', 'w') as cf: