Skip to content

Commit

Permalink
dev(hansbug): remove typing support
Browse files Browse the repository at this point in the history
  • Loading branch information
HansBug committed Aug 29, 2022
1 parent 35086e6 commit 95e9020
Show file tree
Hide file tree
Showing 14 changed files with 5 additions and 372 deletions.
2 changes: 0 additions & 2 deletions potc/rules/native/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
builtin_slice, builtin_range, builtin_bytes, builtin_float, builtin_module, \
builtin_tuple, builtin_func, builtin_type, builtin_dict, builtin_int, builtin_list, builtin_none, builtin_set, \
builtin_str, builtin_items, builtin_complex, builtin_object
from .typing import typing_wrapper, typing_all, typing_typevar, typing_callable, typing_items

native_all = [
typing_all,
builtin_all,
]
149 changes: 0 additions & 149 deletions potc/rules/native/typing.py

This file was deleted.

82 changes: 2 additions & 80 deletions potc/testing/property.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
import types
from functools import partial
from typing import NamedTuple, NoReturn, List, Set, Dict, Tuple, Callable, Any, TypeVar
from typing import NamedTuple

from dill import source

Expand Down Expand Up @@ -78,7 +78,7 @@ def provement(trans=None):
Examples:
>>> import pytest
>>> from potc_dict.plugin import __rules__ # load rules from plugin potc_dict
>>> from potc_typing.plugin import __rules__ # load rules from plugin potc_typing
>>>
>>> from potc.testing import provement
>>> from potc.translate import BlankTranslator
Expand Down Expand Up @@ -332,82 +332,4 @@ def test_mixed_case(self):
'feat': [None, type, int, 233, 'sdfkl', (5, 6, -3 + 1j), {}, set(), []],
}

def test_typing(self):
with transobj_assert(NoReturn) as (obj, name):
assert obj is NoReturn

with transobj_assert(List) as (obj, name):
assert obj == List
with transobj_assert(Dict) as (obj, name):
assert obj == Dict
with transobj_assert(Set) as (obj, name):
assert obj == Set
with transobj_assert(Tuple) as (obj, name):
assert obj == Tuple
with transobj_assert(Callable) as (obj, name):
assert obj == Callable

with transobj_assert(List[int]) as (obj, name):
assert obj == List[int]
with transobj_assert(Dict[int, List[str]]) as (obj, name):
assert obj == Dict[int, List[str]]
with transobj_assert(Set[str]) as (obj, name):
assert obj == Set[str]
with transobj_assert(Tuple[int, str, List[str]]) as (obj, name):
assert obj == Tuple[int, str, List[str]]
with transobj_assert(Callable[..., int]) as (obj, name):
assert obj == Callable[..., int]
with transobj_assert(Callable[[], int]) as (obj, name):
assert obj == Callable[[], int]
with transobj_assert(Callable[[int, Any], str]) as (obj, name):
assert obj == Callable[[int, Any], str]
with transobj_assert(Callable[[int], Any]) as (obj, name):
assert obj == Callable[[int], Any]

try:
_ = list[int]
except TypeError:
pass
else:
with transobj_assert(list[int]) as (obj, name):
assert obj == list[int]
with transobj_assert(dict[int, list[int]]) as (obj, name):
assert obj == dict[int, list[int]]

K = TypeVar('K', bound=int, contravariant=True)
V = TypeVar('V', int, str, covariant=True)

with transobj_assert(K) as (obj, name):
assert isinstance(obj, TypeVar)
assert obj.__name__ == 'K'
assert obj.__constraints__ == ()
assert obj.__bound__ == int
assert not obj.__covariant__
assert obj.__contravariant__

with transobj_assert(V) as (obj, name):
assert isinstance(obj, TypeVar)
assert obj.__name__ == 'V'
assert obj.__constraints__ == (int, str)
assert obj.__bound__ is None
assert obj.__covariant__
assert not obj.__contravariant__

with transobj_assert(Dict[K, V]) as (obj, name):
assert obj.__origin__ in {Dict, dict}
_k, _v = obj.__args__
assert isinstance(_k, TypeVar)
assert _k.__name__ == 'K'
assert _k.__constraints__ == ()
assert _k.__bound__ == int
assert not _k.__covariant__
assert _k.__contravariant__

assert isinstance(_v, TypeVar)
assert _v.__name__ == 'V'
assert _v.__constraints__ == (int, str)
assert _v.__bound__ is None
assert _v.__covariant__
assert not _v.__contravariant__

return _Provement
5 changes: 0 additions & 5 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
from .config import *
from .entry import *
from .fixture import *
from .rules import *
from .translate import *
1 change: 0 additions & 1 deletion test/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .test_meta import TestConfigMeta
1 change: 0 additions & 1 deletion test/entry/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .cli import *
3 changes: 0 additions & 3 deletions test/entry/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .test_export import TestEntryCliExport
from .test_trans import TestEntryCliTrans
from .test_version import TestEntryCliVersion
4 changes: 0 additions & 4 deletions test/fixture/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from .test_addons import TestFixtureAddons
from .test_chain import TestFixtureChain
from .test_common import TestFixtureCommon
from .test_imports import TestFixtureImports
3 changes: 0 additions & 3 deletions test/rules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .native import *
from .test_basic import TestRulesProvementBasic, TestRulesProvementBlank, TestRulesProvementCommon
from .test_installed import TestRulesInstalled
2 changes: 0 additions & 2 deletions test/rules/native/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from .test_builtins import TestRulesNativeBuiltins
from .test_typing import TestRuleNativeTyping
Loading

0 comments on commit 95e9020

Please sign in to comment.