Commit 60b7356d authored by Anton Akhmerov's avatar Anton Akhmerov

internal function formatting cleanup

parent 8bd421b6
Pipeline #14320 failed with stages
in 39 minutes and 33 seconds
......@@ -599,21 +599,23 @@ class BuilderLead(Lead):
return InfiniteSystem(self.builder, self.interface)
# Check that a modes/selfenergy function has a keyword-only parameter
# 'params', or takes '**kwargs'. If not, we wrap it
def _ensure_signature(func):
parameters = inspect.signature(func).parameters
has_params = bool(parameters.get('params'))
has_kwargs = any(p.kind == inspect.Parameter.VAR_KEYWORD
for p in parameters.values())
if has_params or has_kwargs:
return func
else: # function conforming to old API: needs wrapping
def wrapper(energy, args=(), *, params=None):
return func(energy, args)
return wrapper
"""
Ensure that a modes/selfenergy function has a keyword-only parameter
``params``, or takes ``**kwargs`` by potentially wrapping it.
"""
parameters = inspect.signature(func).parameters
has_params = bool(parameters.get('params'))
has_kwargs = any(p.kind == inspect.Parameter.VAR_KEYWORD
for p in parameters.values())
if has_params or has_kwargs:
return func
# function conforming to old API: needs wrapping
def wrapper(energy, args=(), *, params=None):
return func(energy, args)
return wrapper
class SelfEnergyLead(Lead):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment