From 801f7ccc13de7a389173b13dd1aa5175346108ca Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Tue, 30 Jan 2024 12:08:45 -0500 Subject: [PATCH] refactor: python 3.10 style for files I am touching --- everyvoice/cli.py | 3 +-- everyvoice/tests/test_wizard.py | 6 +++--- everyvoice/wizard/__init__.py | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/everyvoice/cli.py b/everyvoice/cli.py index 18783e8a..f777dc66 100644 --- a/everyvoice/cli.py +++ b/everyvoice/cli.py @@ -1,7 +1,6 @@ import json from enum import Enum from pathlib import Path -from typing import Dict import typer from pydantic import BaseModel @@ -238,7 +237,7 @@ def test(suite: TestSuites = typer.Argument(TestSuites.dev)): # Deferred full initialization to optimize the CLI, but still exposed for unit testing. -SCHEMAS_TO_OUTPUT: Dict[str, type[BaseModel]] = {} +SCHEMAS_TO_OUTPUT: dict[str, type[BaseModel]] = {} @app.command(hidden=True) diff --git a/everyvoice/tests/test_wizard.py b/everyvoice/tests/test_wizard.py index f2a28ee1..b337777d 100755 --- a/everyvoice/tests/test_wizard.py +++ b/everyvoice/tests/test_wizard.py @@ -7,7 +7,7 @@ from enum import Enum from pathlib import Path from types import MethodType -from typing import Callable, Iterable, NamedTuple, Optional, Sequence, Union +from typing import Callable, Iterable, NamedTuple, Optional, Sequence from unittest import TestCase, main import yaml @@ -31,7 +31,7 @@ class RecursiveAnswers(NamedTuple): """Recursive answer for StepAndAnswer.children_answers, see StepAndAnswer documentation for a description of the fields here.""" - answer_or_monkey: Union[Say, Callable] + answer_or_monkey: Say | Callable children_answers: Optional[list["RecursiveAnswers"]] = None @@ -49,7 +49,7 @@ class StepAndAnswer(NamedTuple): """ step: Step - answer_or_monkey: Union[Say, Callable] + answer_or_monkey: Say | Callable children_answers: Optional[list[RecursiveAnswers]] = None @property diff --git a/everyvoice/wizard/__init__.py b/everyvoice/wizard/__init__.py index cf4d44a1..e73cc86e 100644 --- a/everyvoice/wizard/__init__.py +++ b/everyvoice/wizard/__init__.py @@ -1,6 +1,6 @@ import sys from enum import Enum -from typing import List, Optional, Union +from typing import Optional from anytree import NodeMixin, RenderTree @@ -54,7 +54,7 @@ class Step(_Step, NodeMixin): def __init__( self, - name: Union[None, Enum, str] = None, + name: None | Enum | str = None, default=None, prompt_method=None, validate_method=None, @@ -109,7 +109,7 @@ def run(self): class Tour: - def __init__(self, name: str, steps: List[Step], state: Optional[dict] = None): + def __init__(self, name: str, steps: list[Step], state: Optional[dict] = None): """Create the tour by setting each Step as the child of the previous Step.""" self.name = name self.state: dict = state if state is not None else {}