Skip to content

Commit

Permalink
fix pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamilcuk committed Oct 10, 2024
1 parent a5e14bc commit 9003365
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/nomad_tools/entry_dockers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def load_job_file(file: IO) -> nomadlib.Job:
@dataclass
class Args:
verbose: int = clickdc.option("-v", count=True, help="Be verbose")
format: Optional[str] = clickdc.option(
format: str = clickdc.option(
"-f",
help="Passed to python .format()",
show_default=True,
Expand Down
22 changes: 15 additions & 7 deletions src/nomad_tools/entry_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ class LogOptions:
)
log_json: bool = clickdc.alias_option(aliased=dict(log_format=LogFormatter.JSON))
log_nospace: bool = clickdc.option(help="Do not print space on log lines")
log_j: Any = clickdc.alias_option(aliased=dict(log_nospace=True, log_format=LogFormatter.ONE))
log_j: Any = clickdc.alias_option(
aliased=dict(log_nospace=True, log_format=LogFormatter.ONE)
)
out: List[str] = clickdc.option(
"-o",
type=CommaList("all alloc stdout stderr eval deploy nolog none".split()),
Expand Down Expand Up @@ -2000,12 +2002,14 @@ class JobIdOrFile(click.ParamType):
def convert(
self, value: Any, param: Optional[click.Parameter], ctx: Optional[click.Context]
) -> str:
exists = lambda : Path(value).exists()
exists = Path(value).exists()
job = None
if any(value.endswith(x) for x in ".hcl .nomad".split()) and exists():
if exists and any(value.endswith(x) for x in ".hcl .nomad".split()):
try:
log.info(f"Extracting job name from file {value} using nomad command")
output = subprocess.check_output("nomad job run -output".split() + [value])
output = subprocess.check_output(
"nomad job run -output".split() + [value]
)
job = json.loads(output)
except subprocess.CalledProcessError:
pass
Expand Down Expand Up @@ -2033,9 +2037,9 @@ def convert(
job["ID"] = jobid
if jobnamespace:
job["Namespace"] = jobnamespace
if value.endswith(".json") and exists():
if exists and value.endswith(".json"):
log.info(f"Extracting job name from json file {value}")
with Path(value) as f:
with Path(value).open() as f:
job = json.load(f)
if job:
job = job.get("Job", job)
Expand All @@ -2049,7 +2053,11 @@ def convert(
def shell_complete(
self, ctx: click.Context, param: click.Parameter, incomplete: str
) -> List[CompletionItem]:
jobs = [CompletionItem(x["ID"]) for x in mynomad.get("jobs") if x["ID"].startswith(incomplete)]
jobs = [
CompletionItem(x["ID"])
for x in mynomad.get("jobs")
if x["ID"].startswith(incomplete)
]
if jobs:
return jobs
return [CompletionItem(incomplete, type="file")]
Expand Down

0 comments on commit 9003365

Please sign in to comment.