Skip to content

Commit e152683

Browse files
committed
Try to make static typing of read() sane
Conclusion: for now we can't support static typing for nested inputs.
1 parent 7ee81ff commit e152683

File tree

2 files changed

+53
-16
lines changed

2 files changed

+53
-16
lines changed

form/formlink.py

+51-16
Original file line numberDiff line numberDiff line change
@@ -340,65 +340,94 @@ def flush(self):
340340
@overload
341341
def read(self, name): # noqa: D102
342342
# type: (str) -> str
343-
pass
343+
pass # pragma: no cover
344344

345345
@overload # noqa: F811
346346
def read(self, name1, name2): # noqa: D102
347347
# type: (str, str) -> Tuple[str, str]
348-
pass
348+
pass # pragma: no cover
349349

350350
@overload # noqa: F811
351351
def read(self, name1, name2, name3): # noqa: D102
352352
# type: (str, str, str) -> Tuple[str, str, str]
353-
pass
353+
pass # pragma: no cover
354354

355355
@overload # noqa: F811
356356
def read(self, name1, name2, name3, name4): # noqa: D102
357357
# type: (str, str, str, str) -> Tuple[str, str, str, str]
358-
pass
358+
pass # pragma: no cover
359359

360360
@overload # noqa: F811
361361
def read(self, name1, name2, name3, name4, name5): # noqa: D102
362362
# type: (str, str, str, str, str) -> Tuple[str, str, str, str, str]
363-
pass
363+
pass # pragma: no cover
364364

365365
@overload # noqa: F811
366366
def read(self, name1, name2, name3, name4, name5, name6): # noqa: D102
367367
# type: (str, str, str, str, str, str) -> Tuple[str, str, str, str, str, str] # noqa: E501
368-
pass
368+
pass # pragma: no cover
369369

370370
@overload # noqa: F811
371371
def read(self, name1, name2, name3, name4, name5, name6, name7): # noqa: D102, E501
372372
# type: (str, str, str, str, str, str, str) -> Tuple[str, str, str, str, str, str, str] # noqa: E501
373-
pass
373+
pass # pragma: no cover
374374

375375
@overload # noqa: F811
376376
def read(self, name1, name2, name3, name4, name5, name6, name7, name8): # noqa: D102, E501
377377
# type: (str, str, str, str, str, str, str, str) -> Tuple[str, str, str, str, str, str, str, str] # noqa: E501
378-
pass
378+
pass # pragma: no cover
379379

380380
@overload # noqa: F811
381381
def read(self, name1, name2, name3, name4, name5, name6, name7, name8, name9): # noqa: D102, E501
382382
# type: (str, str, str, str, str, str, str, str, str) -> Tuple[str, str, str, str, str, str, str, str, str] # noqa: E501
383-
pass
383+
pass # pragma: no cover
384384

385385
@overload # noqa: F811
386386
def read(self, names): # noqa: D102
387-
# type: (Sequence[str]) -> Sequence[str]
388-
pass
387+
# type: (Tuple[str]) -> str
388+
pass # pragma: no cover
389+
390+
@overload # noqa: F811
391+
def read(self, names): # noqa: D102
392+
# type: (Tuple[str, str]) -> Tuple[str, str]
393+
pass # pragma: no cover
394+
395+
@overload # noqa: F811
396+
def read(self, names): # noqa: D102
397+
# type: (Tuple[str, str, str]) -> Tuple[str, str, str]
398+
pass # pragma: no cover
399+
400+
@overload # noqa: F811
401+
def read(self, names): # noqa: D102
402+
# type: (Tuple[str, str, str, str]) -> Tuple[str, str, str, str]
403+
pass # pragma: no cover
404+
405+
@overload # noqa: F811
406+
def read(self, names): # noqa: D102
407+
# type: (Tuple[str, str, str, str, str]) -> Tuple[str, str, str, str, str] # noqa: E501
408+
pass # pragma: no cover
409+
410+
@overload # noqa: F811
411+
def read(self, names): # noqa: D102
412+
# type: (Tuple[str, str, str, str, str, str]) -> Tuple[str, str, str, str, str, str] # noqa: E501
413+
pass # pragma: no cover
414+
415+
@overload # noqa: F811
416+
def read(self, names): # noqa: D102
417+
# type: (Tuple[str, str, str, str, str, str, str]) -> Tuple[str, str, str, str, str, str, str] # noqa: E501
418+
pass # pragma: no cover
389419

390420
@overload # noqa: F811
391421
def read(self, *names): # noqa: D102
392422
# type: (str) -> Sequence[str]
393-
pass
423+
pass # pragma: no cover
394424

395425
@overload # noqa: F811
396-
def read(self, *names): # noqa: D102
397-
# type: (Any) -> Any
398-
pass
426+
def read(self, names): # noqa: D102
427+
# type: (Sequence[str]) -> Sequence[str]
428+
pass # pragma: no cover
399429

400430
def read(self, *names): # type: ignore # noqa: F811
401-
# type: (Any) -> Any
402431
r"""Read results from FORM.
403432
404433
Wait for a response of FORM to obtain the results specified by
@@ -447,6 +476,12 @@ def read(self, *names): # type: ignore # noqa: F811
447476
['a1', ['a2', 'a3']]
448477
449478
>>> f.close()
479+
480+
Note
481+
----
482+
Currently nested inputs are not supported for static typing. You need
483+
``# type: ignore`` or other hacks.
484+
450485
"""
451486
if self._closed:
452487
raise IOError('tried to read from closed connection')

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55

66
def readme():
7+
# type: () -> str
78
"""Read the README file."""
89
with open('README.rst') as f:
910
return f.read()
1011

1112

1213
def setup_package():
14+
# type: () -> None
1315
"""Entry point."""
1416
setup(
1517
name='python-form',

0 commit comments

Comments
 (0)