From 613da7122cb16a461155f4e0c989a0b2aed310f3 Mon Sep 17 00:00:00 2001 From: Konstantin Chernyshev Date: Sat, 16 Dec 2023 17:56:20 +0100 Subject: [PATCH] fix: add missing future annotation --- checker/configs/utils.py | 6 ++++-- checker/pipeline.py | 2 +- checker/plugins/__init__.py | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/checker/configs/utils.py b/checker/configs/utils.py index 13eeaea..2c2760a 100644 --- a/checker/configs/utils.py +++ b/checker/configs/utils.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import re from pathlib import Path from typing import Any, Generic, TypeVar, Type, Protocol @@ -25,7 +27,7 @@ class CustomBaseModel(pydantic.BaseModel): class YamlLoaderMixin(Generic[T]): @classmethod - def from_yaml(cls: Type[T], path: Path) -> T: + def from_yaml(cls: type[T], path: Path) -> T: try: with path.open() as f: return cls(**yaml.safe_load(f)) @@ -41,5 +43,5 @@ def to_yaml(self: T, path: Path) -> None: yaml.dump(self.model_dump(), f) @classmethod - def get_json_schema(cls: Type[T]) -> dict[str, Any]: + def get_json_schema(cls: type[T]) -> dict[str, Any]: return cls.model_json_schema() diff --git a/checker/pipeline.py b/checker/pipeline.py index 43c2aa2..78d87f4 100644 --- a/checker/pipeline.py +++ b/checker/pipeline.py @@ -81,7 +81,7 @@ class PipelineRunner: def __init__( self, pipeline: list[PipelineStageConfig], - plugins: dict[str, Type[PluginABC]], + plugins: dict[str, type[PluginABC]], *, verbose: bool = False, ): diff --git a/checker/plugins/__init__.py b/checker/plugins/__init__.py index 799824f..4eb3d51 100644 --- a/checker/plugins/__init__.py +++ b/checker/plugins/__init__.py @@ -6,7 +6,6 @@ import sys from collections.abc import Sequence from pathlib import Path -from typing import Type from .base import PluginABC, PluginOutput # noqa: F401 @@ -18,7 +17,7 @@ ] -def get_all_subclasses(cls: Type[PluginABC]) -> set[type[PluginABC]]: +def get_all_subclasses(cls: type[PluginABC]) -> set[type[PluginABC]]: return set(cls.__subclasses__()).union( [s for c in cls.__subclasses__() for s in get_all_subclasses(c)] ) @@ -28,7 +27,7 @@ def load_plugins( search_directories: Sequence[str | Path] | None = None, *, verbose: bool = False, -) -> dict[str, Type[PluginABC]]: +) -> dict[str, type[PluginABC]]: """ Load plugins from the plugins directory. :param search_directories: list of directories to search for plugins