summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2023-05-24 20:54:17 -0400
committerJeff Forcier <jeff@bitprophet.org>2023-05-24 20:54:26 -0400
commitfd068633004b2635ffd71e3ad881455e053ae1d8 (patch)
treeaafba4693fc5be20fdf39a09f6befcc49a68c6c1
parent72898dbd77a94b91f77f47e15c7d206c5c41bef6 (diff)
TODO/tweak to PKey.__repr__
-rw-r--r--paramiko/pkey.py8
-rw-r--r--tests/auth.py4
2 files changed, 9 insertions, 3 deletions
diff --git a/paramiko/pkey.py b/paramiko/pkey.py
index 60e5a8fc..ef371002 100644
--- a/paramiko/pkey.py
+++ b/paramiko/pkey.py
@@ -249,12 +249,18 @@ class PKey:
"""
pass
+ # TODO: arguably this might want to be __str__ instead? ehh
+ # TODO: ditto the interplay between showing class name (currently we just
+ # say PKey writ large) and algorithm (usually == class name, but not
+ # always, also sometimes shows certificate-ness)
+ # TODO: if we do change it, we also want to tweak eg AgentKey, as it
+ # currently displays agent-ness with a suffix
def __repr__(self):
comment = ""
# Works for AgentKey, may work for others?
if hasattr(self, "comment") and self.comment:
comment = f", comment={self.comment!r}"
- return f"{self.__class__.__name__}(alg={self.algorithm_name}, bits={self.get_bits()}, fp={self.fingerprint}{comment})" # noqa
+ return f"PKey(alg={self.algorithm_name}, bits={self.get_bits()}, fp={self.fingerprint}{comment})" # noqa
# TODO 4.0: just merge into __bytes__ (everywhere)
def asbytes(self):
diff --git a/tests/auth.py b/tests/auth.py
index 52544e88..c0afe889 100644
--- a/tests/auth.py
+++ b/tests/auth.py
@@ -404,7 +404,7 @@ class AuthSource_:
source = InMemoryPrivateKey("foo", pkey)
assert (
repr(source)
- == "InMemoryPrivateKey(pkey=Ed25519Key(alg=ED25519, bits=256, fp=SHA256:J6VESFdD3xSChn8y9PzWzeF+1tl892mOy2TqkMLO4ow))" # noqa
+ == "InMemoryPrivateKey(pkey=PKey(alg=ED25519, bits=256, fp=SHA256:J6VESFdD3xSChn8y9PzWzeF+1tl892mOy2TqkMLO4ow))" # noqa
)
def repr_appends_agent_flag_when_AgentKey(self):
@@ -413,7 +413,7 @@ class AuthSource_:
source = InMemoryPrivateKey("foo", pkey)
assert (
repr(source)
- == "InMemoryPrivateKey(pkey=AgentKey(alg=ED25519, bits=256, fp=SHA256:J6VESFdD3xSChn8y9PzWzeF+1tl892mOy2TqkMLO4ow)) [agent]" # noqa
+ == "InMemoryPrivateKey(pkey=PKey(alg=ED25519, bits=256, fp=SHA256:J6VESFdD3xSChn8y9PzWzeF+1tl892mOy2TqkMLO4ow)) [agent]" # noqa
)
class OnDiskPrivateKey_: