Skip to content

Commit

Permalink
manually duplicate signature
Browse files Browse the repository at this point in the history
  • Loading branch information
mishaschwartz committed Feb 15, 2024
1 parent 41e581c commit e7e3670
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions weaver/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,18 @@ class RequestAuthHandler(AuthHandler, HTTPBasicAuth):
Base class to send a request in order to retrieve an authorization token.
"""

def __init__(self, token=None, **kwargs):
# type: (Any, **Any) -> None
AuthHandler.__init__(self, **kwargs)
HTTPBasicAuth.__init__(self, username=kwargs.get("username"), password=kwargs.get("password"))
def __init__(self,
identity=None, # Optional[str]
password=None, # Optional[str]
url=None, # Optional[str]
method="GET", # AnyRequestMethod
headers=None, # Optional[AnyHeadersContainer]
token=None): # Any
# type: (...) -> None
AuthHandler.__init__(self, identity=identity, password=password, url=url, method=method, headers=headers)
HTTPBasicAuth.__init__(self, username=identity, password=password)
self.token = token

# Update __init__'s signature to include keyword arguments from AuthHandler's __init__. This is required because
# the CLI entrypoint inspects the auth class' signature in order to figure out which arguments to pass to it.
_signature_AuthHandler = inspect.signature(AuthHandler.__init__)
__init__.__signature__ = _signature_AuthHandler.replace(
parameters=(*_signature_AuthHandler.parameters.values(), inspect.signature(__init__).parameters["token"])
)

@property
def auth_token_name(self):
# type: () -> str
Expand Down Expand Up @@ -2961,6 +2960,7 @@ def main(*args):
except Exception as exc:
msg = "Operation failed due to exception."
err = fully_qualified_name(exc)
result = OperationResult(False, message=msg, body={"message": msg, "cause": str(exc), "error": err})
if result.success:
LOGGER.info("%s successful. %s\n", oper.title(), result.message)
print(result.text) # use print in case logger disabled or level error/warn
Expand Down

0 comments on commit e7e3670

Please sign in to comment.