diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2023-05-24 20:54:17 -0400 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2023-05-24 20:54:26 -0400 |
commit | fd068633004b2635ffd71e3ad881455e053ae1d8 (patch) | |
tree | aafba4693fc5be20fdf39a09f6befcc49a68c6c1 | |
parent | 72898dbd77a94b91f77f47e15c7d206c5c41bef6 (diff) |
TODO/tweak to PKey.__repr__
-rw-r--r-- | paramiko/pkey.py | 8 | ||||
-rw-r--r-- | tests/auth.py | 4 |
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_: |