ovld 0.4.5__py3-none-any.whl → 0.4.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ovld/dependent.py +2 -1
- ovld/mro.py +5 -0
- ovld/py.typed +0 -0
- ovld/types.py +11 -7
- ovld/utils.py +11 -0
- ovld/version.py +1 -1
- {ovld-0.4.5.dist-info → ovld-0.4.6.dist-info}/METADATA +1 -1
- ovld-0.4.6.dist-info/RECORD +15 -0
- ovld-0.4.5.dist-info/RECORD +0 -14
- {ovld-0.4.5.dist-info → ovld-0.4.6.dist-info}/WHEEL +0 -0
- {ovld-0.4.5.dist-info → ovld-0.4.6.dist-info}/licenses/LICENSE +0 -0
ovld/dependent.py
CHANGED
@@ -15,6 +15,7 @@ from .types import (
|
|
15
15
|
Intersection,
|
16
16
|
Order,
|
17
17
|
clsstring,
|
18
|
+
get_args,
|
18
19
|
normalize_type,
|
19
20
|
subclasscheck,
|
20
21
|
typeorder,
|
@@ -61,7 +62,7 @@ def combine(master_template, args):
|
|
61
62
|
def is_dependent(t):
|
62
63
|
if isinstance(t, DependentType):
|
63
64
|
return True
|
64
|
-
elif any(is_dependent(subt) for subt in
|
65
|
+
elif any(is_dependent(subt) for subt in get_args(t)):
|
65
66
|
return True
|
66
67
|
return False
|
67
68
|
|
ovld/mro.py
CHANGED
@@ -3,6 +3,8 @@ from enum import Enum
|
|
3
3
|
from graphlib import TopologicalSorter
|
4
4
|
from typing import get_args, get_origin
|
5
5
|
|
6
|
+
from .utils import UnionTypes
|
7
|
+
|
6
8
|
|
7
9
|
class Order(Enum):
|
8
10
|
LESS = -1
|
@@ -121,6 +123,9 @@ def subclasscheck(t1, t2):
|
|
121
123
|
):
|
122
124
|
return result
|
123
125
|
|
126
|
+
if t2 in UnionTypes:
|
127
|
+
return isinstance(t1, t2)
|
128
|
+
|
124
129
|
o1 = get_origin(t1)
|
125
130
|
o2 = get_origin(t2)
|
126
131
|
|
ovld/py.typed
ADDED
File without changes
|
ovld/types.py
CHANGED
@@ -3,16 +3,18 @@ import sys
|
|
3
3
|
import typing
|
4
4
|
from dataclasses import dataclass
|
5
5
|
from functools import partial
|
6
|
-
from typing import Protocol, runtime_checkable
|
6
|
+
from typing import Protocol, get_args, runtime_checkable
|
7
7
|
|
8
8
|
from .mro import Order, TypeRelationship, subclasscheck, typeorder
|
9
9
|
from .typemap import TypeMap
|
10
|
-
from .utils import UsageError, clsstring
|
10
|
+
from .utils import UnionType, UnionTypes, UsageError, clsstring
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
|
13
|
+
def get_args(tp):
|
14
|
+
args = getattr(tp, "__args__", None)
|
15
|
+
if not isinstance(args, tuple):
|
16
|
+
args = ()
|
17
|
+
return args
|
16
18
|
|
17
19
|
|
18
20
|
class TypeNormalizer:
|
@@ -37,6 +39,8 @@ class TypeNormalizer:
|
|
37
39
|
t = object
|
38
40
|
elif t is inspect._empty:
|
39
41
|
t = object
|
42
|
+
elif t in UnionTypes:
|
43
|
+
return type[t]
|
40
44
|
elif isinstance(t, typing._AnnotatedAlias):
|
41
45
|
t = t.__origin__
|
42
46
|
|
@@ -82,7 +86,7 @@ class MetaMC(type):
|
|
82
86
|
return super().__new__(T, name, (), {"_handler": handler})
|
83
87
|
|
84
88
|
def __init__(cls, name, handler):
|
85
|
-
cls.__args__ =
|
89
|
+
cls.__args__ = get_args(handler)
|
86
90
|
|
87
91
|
def codegen(cls):
|
88
92
|
return cls._handler.codegen()
|
ovld/utils.py
CHANGED
@@ -5,6 +5,15 @@ import re
|
|
5
5
|
import typing
|
6
6
|
from itertools import count
|
7
7
|
|
8
|
+
try:
|
9
|
+
from types import UnionType
|
10
|
+
|
11
|
+
UnionTypes = (type(typing.Union[int, str]), UnionType)
|
12
|
+
|
13
|
+
except ImportError: # pragma: no cover
|
14
|
+
UnionType = None
|
15
|
+
UnionTypes = (type(typing.Union[int, str]),)
|
16
|
+
|
8
17
|
|
9
18
|
class Named:
|
10
19
|
"""A named object.
|
@@ -90,6 +99,8 @@ def clsstring(cls):
|
|
90
99
|
def subtler_type(obj):
|
91
100
|
if isinstance(obj, GenericAlias):
|
92
101
|
return type[obj]
|
102
|
+
elif isinstance(obj, UnionTypes):
|
103
|
+
return type[obj]
|
93
104
|
elif obj is typing.Any:
|
94
105
|
return type[object]
|
95
106
|
elif isinstance(obj, type):
|
ovld/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = "0.4.
|
1
|
+
version = "0.4.6"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
ovld/__init__.py,sha256=IVzs4_9skMa_UGZsGT7Ra_dIxj7KKNlV77XxlqcS6ow,1446
|
2
|
+
ovld/abc.py,sha256=4qpZyYwI8dWgY1Oiv5FhdKg2uzNcyWxIpGmGJVcjXrs,1177
|
3
|
+
ovld/core.py,sha256=MtRcJNhMwsix2Y7zP1fQS-taCy_t0bqkjHQdLF8WE8E,25719
|
4
|
+
ovld/dependent.py,sha256=M85EJPRGNnEpmsr3tEX1U-1di1cxQb5-0oQtLgvfRoA,10183
|
5
|
+
ovld/mro.py,sha256=D9KY3KEFnWL_SXZqHsVKNgRM1E0d8TPPILVZ3SxdUb4,4643
|
6
|
+
ovld/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
ovld/recode.py,sha256=bwsdM-TPpSQEmJhv8G30yDLrF8_I5wyTXpITMCC1W9k,17961
|
8
|
+
ovld/typemap.py,sha256=PH5dy8ddVCcqj2TkQbgsM7fmCdHsJT9WGXFPn4JZsCA,13131
|
9
|
+
ovld/types.py,sha256=lvOl1fldIqCJM-TvvdM2nMvAYDgcA45awfpkUB6kKpo,12984
|
10
|
+
ovld/utils.py,sha256=k-cVMbJigtdeuD5_JEYtq1a6fXhmUGqLfBu8YxYd5VY,3395
|
11
|
+
ovld/version.py,sha256=DWNNbWBv-hyqVy76bKbnHWaDUbqL0BOtdkPSV_88dx0,18
|
12
|
+
ovld-0.4.6.dist-info/METADATA,sha256=mXEwvqopBdpksDEKETVZkp-airCb48yt4AWZIQ2r2wU,7833
|
13
|
+
ovld-0.4.6.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
14
|
+
ovld-0.4.6.dist-info/licenses/LICENSE,sha256=cSwNTIzd1cbI89xt3PeZZYJP2y3j8Zus4bXgo4svpX8,1066
|
15
|
+
ovld-0.4.6.dist-info/RECORD,,
|
ovld-0.4.5.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
ovld/__init__.py,sha256=IVzs4_9skMa_UGZsGT7Ra_dIxj7KKNlV77XxlqcS6ow,1446
|
2
|
-
ovld/abc.py,sha256=4qpZyYwI8dWgY1Oiv5FhdKg2uzNcyWxIpGmGJVcjXrs,1177
|
3
|
-
ovld/core.py,sha256=MtRcJNhMwsix2Y7zP1fQS-taCy_t0bqkjHQdLF8WE8E,25719
|
4
|
-
ovld/dependent.py,sha256=nyrkkmgxGjcHnZjKqbk7_g4_D91SYfYTPIE32LOvC9o,10184
|
5
|
-
ovld/mro.py,sha256=0cJK_v-POCiuwjluwf8fWeQ3G-2chEUv3KYe57GC61Q,4552
|
6
|
-
ovld/recode.py,sha256=bwsdM-TPpSQEmJhv8G30yDLrF8_I5wyTXpITMCC1W9k,17961
|
7
|
-
ovld/typemap.py,sha256=PH5dy8ddVCcqj2TkQbgsM7fmCdHsJT9WGXFPn4JZsCA,13131
|
8
|
-
ovld/types.py,sha256=EZNv8pThbo47KBULYM3R0R3sM2C5LC4DWraXZImkiNs,12877
|
9
|
-
ovld/utils.py,sha256=jrrG_BqjI3W7x285nLuYiy5ui9LbNltblFVTlOWHYiU,3123
|
10
|
-
ovld/version.py,sha256=GzDw9yI90LiIOYlw5gZBih8gPe3URgiM0vAFi2-I3ro,18
|
11
|
-
ovld-0.4.5.dist-info/METADATA,sha256=AM7DiTgyU53Z0A7s8MIJJ3t1rgk1pxf3uqPU20kVO6o,7833
|
12
|
-
ovld-0.4.5.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
13
|
-
ovld-0.4.5.dist-info/licenses/LICENSE,sha256=cSwNTIzd1cbI89xt3PeZZYJP2y3j8Zus4bXgo4svpX8,1066
|
14
|
-
ovld-0.4.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|