Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: Fix linting in Credential class #137

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions revup/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,37 +807,37 @@ async def soft_reset(self, new_commit: GitCommitHash, env: Dict) -> None:
# TODO: only strictly needs to drop entries for HEAD
self.clear_cache()

async def credential(self, **kwargs: Dict[str, str]) -> str:
async def credential(self, **kwargs: str) -> str:
cred = Credential(self, description=kwargs)
await cred.fill()
return cred.password


class Credential():
class Credential:
git_ctx: Git
description: Dict[str, str]

def __init__(self, git: Git, description: Dict[str, str]):
self.git_ctx = git
self.description = description

def __getattr__(self, attr):
def __getattr__(self, attr: str) -> Any:
return self.description[attr]

async def _run(self, subcommand, input: Dict[str, str]) -> Dict[str, str]:
input_str = "\n".join(f"{k}={v}" for k, v in input.items())
async def _run(self, subcommand: str, args: Dict[str, str]) -> Dict[str, str]:
input_str = "\n".join(f"{k}={v}" for k, v in args.items())
stdout_str = await self.git_ctx.git_stdout("credential", subcommand, input_str=input_str)
stdout = {}
stdout_dict = {}
for line in stdout_str.splitlines():
if line == "":
break
k, v = line.split("=", 1)
stdout[k] = v
return stdout
stdout_dict[k] = v
return stdout_dict

async def fill(self):
async def fill(self) -> None:
self.description = await self._run("fill", self.description)

async def report(self, success: bool):
async def report(self, success: bool) -> None:
cmd = "approve" if success else "reject"
await self._run(cmd, self.description)