Skip to content

Commit

Permalink
use typing.Protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
m.kindritskiy committed Sep 15, 2024
1 parent 63cc321 commit 2c9437f
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion hiku/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
Iterator,
Optional,
Callable,
Protocol,
)

from prometheus_client import Counter

from hiku.compat import Protocol
from hiku.result import Index
from hiku.graph import (
Many,
Expand Down
10 changes: 0 additions & 10 deletions hiku/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import ast as _ast
from typing import Any

# TODO: maybe we can remove this version check
PY38: bool = sys.version_info >= (3, 8)
PY310: bool = sys.version_info >= (3, 10)


Expand All @@ -22,18 +20,10 @@ def __getattr__(self, name: str) -> Any:
else:
from typing_extensions import Concatenate, ParamSpec, TypeAlias

# TODO: maybe we can remove this custom class ?
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol


__all__ = [
"PY38",
"PY310",
"ast",
"Protocol",
"Concatenate",
"ParamSpec",
"TypeAlias",
Expand Down
2 changes: 1 addition & 1 deletion hiku/executors/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
Iterable,
Set,
Union,
Protocol,
)

from hiku.compat import Protocol
from hiku.executors.base import BaseExecutor
from hiku.result import Proxy

Expand Down
2 changes: 1 addition & 1 deletion hiku/validate/graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typing as t
from typing import Protocol

from itertools import chain
from contextlib import contextmanager
Expand All @@ -20,7 +21,6 @@
)
from ..graph import AbstractNode, AbstractField, AbstractLink, AbstractOption

from ..compat import Protocol
from .errors import Errors
from ..scalar import Scalar
from ..types import GenericMeta, OptionalMeta
Expand Down
3 changes: 0 additions & 3 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from collections import OrderedDict

import astor
import pytest

from hiku.types import Optional, String, Record, Any, TypeRef, Sequence
from hiku.graph import Graph, Field, Node, Link, Root
from hiku.compat import PY38
from hiku.expr.core import define, S, if_, each, to_expr, if_some
from hiku.expr.checker import check, fn_types
from hiku.expr.compiler import ExpressionCompiler
Expand Down Expand Up @@ -169,7 +167,6 @@ def test_generic_none():
check_compiles(None, "None")


@pytest.mark.skipif(not PY38, reason="Python < 3.8")
def test_generic_bool():
check_compiles(True, "(True)")

Expand Down

0 comments on commit 2c9437f

Please sign in to comment.