Skip to content

Commit

Permalink
Try to make static typing of read() sane
Browse files Browse the repository at this point in the history
Conclusion: for now we can't support static typing for nested inputs.
  • Loading branch information
tueda committed Aug 27, 2019
1 parent 7ee81ff commit da7a999
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions form/formlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,37 @@ def read(self, name1, name2, name3, name4, name5, name6, name7, name8, name9):

@overload # noqa: F811
def read(self, names): # noqa: D102
# type: (Sequence[str]) -> Sequence[str]
# type: (Tuple[str]) -> str
pass

@overload # noqa: F811
def read(self, names): # noqa: D102
# type: (Tuple[str, str]) -> Tuple[str, str]
pass

@overload # noqa: F811
def read(self, names): # noqa: D102
# type: (Tuple[str, str, str]) -> Tuple[str, str, str]
pass

@overload # noqa: F811
def read(self, names): # noqa: D102
# type: (Tuple[str, str, str, str]) -> Tuple[str, str, str, str]
pass

@overload # noqa: F811
def read(self, names): # noqa: D102
# type: (Tuple[str, str, str, str, str]) -> Tuple[str, str, str, str, str] # noqa: E501
pass

@overload # noqa: F811
def read(self, names): # noqa: D102
# type: (Tuple[str, str, str, str, str, str]) -> Tuple[str, str, str, str, str, str] # noqa: E501
pass

@overload # noqa: F811
def read(self, names): # noqa: D102
# type: (Tuple[str, str, str, str, str, str, str]) -> Tuple[str, str, str, str, str, str, str] # noqa: E501
pass

@overload # noqa: F811
Expand All @@ -393,12 +423,11 @@ def read(self, *names): # noqa: D102
pass

@overload # noqa: F811
def read(self, *names): # noqa: D102
# type: (Any) -> Any
def read(self, names): # noqa: D102
# type: (Sequence[str]) -> Sequence[str]
pass

def read(self, *names): # type: ignore # noqa: F811
# type: (Any) -> Any
r"""Read results from FORM.
Wait for a response of FORM to obtain the results specified by
Expand Down Expand Up @@ -447,6 +476,11 @@ def read(self, *names): # type: ignore # noqa: F811
['a1', ['a2', 'a3']]
>>> f.close()
.. note::
Currently nested lists are not supported for static typing.
You need `# type: ignore`.
"""
if self._closed:
raise IOError('tried to read from closed connection')
Expand Down

0 comments on commit da7a999

Please sign in to comment.