pyright complains (wrongly I think) about value being None when passed to Path
to create the socket variable. Let's work around this by eliminating Nones as
values.
return ["/" + os.path.normpath(p).lstrip("/") for p in value.split(",") if p]
-def parse_ssh_agent(value: Optional[str]) -> Optional[Path]:
+def parse_ssh_agent(value: str) -> Optional[Path]:
"""Will return None or a path to a socket."""
- if value is None:
+ if not value:
return None
try:
except ValueError:
pass
else:
- value = os.getenv("SSH_AUTH_SOCK")
+ value = os.getenv("SSH_AUTH_SOCK", "")
if not value:
die("--ssh-agent=true but $SSH_AUTH_SOCK is not set (consider running 'sudo' with '-E')")
group.add_argument(
"--ssh-agent",
type=parse_ssh_agent,
- default=None,
+ default="",
metavar="PATH",
help="Path to the ssh agent socket, or true to use $SSH_AUTH_SOCK.",
)