From 459de566746d6d91f09ce4274f8bd5dbe329a3e6 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Sun, 28 Jan 2024 13:42:05 +0000 Subject: [PATCH] Bump pyupgrade to 3.9 plus and make fixes --- .pre-commit-config.yaml | 2 +- src/jobflow_remote/cli/admin.py | 3 ++- src/jobflow_remote/cli/execution.py | 3 +-- src/jobflow_remote/cli/jf.py | 3 ++- src/jobflow_remote/cli/jfr_typer.py | 6 +++--- src/jobflow_remote/cli/job.py | 3 +-- src/jobflow_remote/cli/project.py | 3 ++- src/jobflow_remote/cli/runner.py | 2 +- src/jobflow_remote/cli/types.py | 11 +++++------ src/jobflow_remote/jobs/runner.py | 6 +++--- src/jobflow_remote/utils/db.py | 3 ++- src/jobflow_remote/utils/schedule.py | 1 + 12 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb57c56f..ca7c6ce7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,4 +67,4 @@ repos: rev: v3.15.0 hooks: - id: pyupgrade - args: [--py38-plus] + args: [--py39-plus] diff --git a/src/jobflow_remote/cli/admin.py b/src/jobflow_remote/cli/admin.py index f8b16c4f..42cbe161 100644 --- a/src/jobflow_remote/cli/admin.py +++ b/src/jobflow_remote/cli/admin.py @@ -1,7 +1,8 @@ +from typing import Annotated + import typer from rich.prompt import Confirm from rich.text import Text -from typing_extensions import Annotated from jobflow_remote.cli.jf import app from jobflow_remote.cli.jfr_typer import JFRTyper diff --git a/src/jobflow_remote/cli/execution.py b/src/jobflow_remote/cli/execution.py index 4e703d89..08dc3113 100644 --- a/src/jobflow_remote/cli/execution.py +++ b/src/jobflow_remote/cli/execution.py @@ -1,7 +1,6 @@ -from typing import Optional +from typing import Annotated, Optional import typer -from typing_extensions import Annotated from jobflow_remote.cli.jf import app from jobflow_remote.cli.jfr_typer import JFRTyper diff --git a/src/jobflow_remote/cli/jf.py b/src/jobflow_remote/cli/jf.py index b2cf0269..72743d04 100644 --- a/src/jobflow_remote/cli/jf.py +++ b/src/jobflow_remote/cli/jf.py @@ -1,6 +1,7 @@ +from typing import Annotated + import typer from rich.text import Text -from typing_extensions import Annotated from jobflow_remote.cli.jfr_typer import JFRTyper from jobflow_remote.cli.utils import ( diff --git a/src/jobflow_remote/cli/jfr_typer.py b/src/jobflow_remote/cli/jfr_typer.py index e20ce659..f16434c6 100644 --- a/src/jobflow_remote/cli/jfr_typer.py +++ b/src/jobflow_remote/cli/jfr_typer.py @@ -13,9 +13,9 @@ class JFRTyper(typer.Typer): def __init__(self, *args, **kwargs): if "epilog" not in kwargs: - kwargs[ - "epilog" - ] = "Run [bold]'jf -h'[/] to display the [bold]global options[/]" + kwargs["epilog"] = ( + "Run [bold]'jf -h'[/] to display the [bold]global options[/]" + ) if "rich_markup_mode" not in kwargs: kwargs["rich_markup_mode"] = "rich" diff --git a/src/jobflow_remote/cli/job.py b/src/jobflow_remote/cli/job.py index d9a678cf..5abd58a8 100644 --- a/src/jobflow_remote/cli/job.py +++ b/src/jobflow_remote/cli/job.py @@ -1,13 +1,12 @@ import io from pathlib import Path -from typing import Optional +from typing import Annotated, Optional import typer from monty.json import jsanitize from monty.serialization import dumpfn from qtoolkit.core.data_objects import QResources from rich.pretty import pprint -from typing_extensions import Annotated from jobflow_remote import SETTINGS from jobflow_remote.cli.formatting import format_job_info, get_job_info_table diff --git a/src/jobflow_remote/cli/project.py b/src/jobflow_remote/cli/project.py index 69ff6374..edada488 100644 --- a/src/jobflow_remote/cli/project.py +++ b/src/jobflow_remote/cli/project.py @@ -1,7 +1,8 @@ +from typing import Annotated + import typer from rich.prompt import Confirm from rich.text import Text -from typing_extensions import Annotated from jobflow_remote.cli.formatting import get_exec_config_table, get_worker_table from jobflow_remote.cli.jf import app diff --git a/src/jobflow_remote/cli/runner.py b/src/jobflow_remote/cli/runner.py index 856e90bf..4db0ab6c 100644 --- a/src/jobflow_remote/cli/runner.py +++ b/src/jobflow_remote/cli/runner.py @@ -1,9 +1,9 @@ import os +from typing import Annotated import typer from rich.table import Table from rich.text import Text -from typing_extensions import Annotated from jobflow_remote.cli.jf import app from jobflow_remote.cli.jfr_typer import JFRTyper diff --git a/src/jobflow_remote/cli/types.py b/src/jobflow_remote/cli/types.py index 35c43f41..4ca5af79 100644 --- a/src/jobflow_remote/cli/types.py +++ b/src/jobflow_remote/cli/types.py @@ -1,17 +1,16 @@ import json from datetime import datetime -from typing import List, Optional +from typing import Annotated, Optional import click import typer -from typing_extensions import Annotated from jobflow_remote.cli.utils import SerializeFileFormat, SortOption from jobflow_remote.config.base import LogLevel from jobflow_remote.jobs.state import FlowState, JobState job_ids_indexes_opt = Annotated[ - Optional[List[str]], + Optional[list[str]], typer.Option( "--job-id", "-jid", @@ -23,7 +22,7 @@ job_ids_opt = Annotated[ - Optional[List[str]], + Optional[list[str]], typer.Option( "--job-id", "-jid", @@ -34,7 +33,7 @@ db_ids_opt = Annotated[ - Optional[List[str]], + Optional[list[str]], typer.Option( "--db-id", "-did", @@ -44,7 +43,7 @@ flow_ids_opt = Annotated[ - Optional[List[str]], + Optional[list[str]], typer.Option( "--flow-id", "-fid", diff --git a/src/jobflow_remote/jobs/runner.py b/src/jobflow_remote/jobs/runner.py index 12f94702..386752b3 100644 --- a/src/jobflow_remote/jobs/runner.py +++ b/src/jobflow_remote/jobs/runner.py @@ -737,9 +737,9 @@ def check_run_status(self): raise RemoteError(error, False) set_output = { "$set": { - "remote.queue_state": qstate.value - if qstate - else None, + "remote.queue_state": ( + qstate.value if qstate else None + ), "state": next_state.value, } } diff --git a/src/jobflow_remote/utils/db.py b/src/jobflow_remote/utils/db.py index f84504fb..67b6ea5d 100644 --- a/src/jobflow_remote/utils/db.py +++ b/src/jobflow_remote/utils/db.py @@ -5,8 +5,9 @@ import time import warnings from collections import defaultdict +from collections.abc import Iterable, Mapping from datetime import datetime -from typing import TYPE_CHECKING, Any, Iterable, Mapping +from typing import TYPE_CHECKING, Any from jobflow.utils import suuid from pymongo import ReturnDocument diff --git a/src/jobflow_remote/utils/schedule.py b/src/jobflow_remote/utils/schedule.py index 47cb25f6..a76322a9 100644 --- a/src/jobflow_remote/utils/schedule.py +++ b/src/jobflow_remote/utils/schedule.py @@ -1,6 +1,7 @@ """ Scheduling tools based on the schedule module """ + from __future__ import annotations import logging