Skip to content

Commit abf68bf

Browse files
committed
Add annotation stubs for annotation variables that weren't previously defined
If we ever end up using the annotations in the tests themselves we will likely need to update the stub types in _types.py to be more sophisticated. For now, though, the annotations are only included in the stubs for completeness and convenience, and _types.py is only used to make pyflakes work.
1 parent 966994f commit abf68bf

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

generate_stubs.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,30 @@
9898
SupportsDLPack = TypeVar('SupportsDLPack')
9999
SupportsBufferProtocol = TypeVar('SupportsBufferProtocol')
100100
PyCapsule = TypeVar('PyCapsule')
101-
102-
__all__ = ['Any', 'List', 'Literal', 'Optional', 'Tuple', 'Union', 'array', 'device',
103-
'dtype', 'SupportsDLPack', 'SupportsBufferProtocol', 'PyCapsule']
101+
# ellipsis cannot actually be imported from anywhere, so include a dummy here
102+
# to keep pyflakes happy. https://github.com/python/typeshed/issues/3556
103+
ellipsis = TypeVar('ellipsis')
104+
105+
@dataclass
106+
class finfo_object:
107+
bits: int
108+
eps: float
109+
max: float
110+
min: float
111+
smallest_normal: float
112+
113+
@dataclass
114+
class iinfo_object:
115+
bits: int
116+
max: int
117+
min: int
118+
119+
# This should really be recursive, but that isn't supported yet.
120+
NestedSequence = Sequence[Sequence[Any]]
121+
122+
__all__ = ['Any', 'List', 'Literal', 'NestedSequence', 'Optional',
123+
'PyCapsule', 'SupportsBufferProtocol', 'SupportsDLPack', 'Tuple', 'Union',
124+
'array', 'device', 'dtype', 'ellipsis', 'finfo_object', 'iinfo_object']
104125
105126
'''
106127
def main():

0 commit comments

Comments
 (0)