MLH-Fellowship / pyre-check

Performant type-checking for python.
https://pyre-check.org/
MIT License
3 stars 1 forks source link

[Fall 2021] Step 1: Pyre - Fix type checking errors in Pytorch `torch/_VF.pyi` #61

Open 0xedward opened 3 years ago

0xedward commented 3 years ago

This task is part of a bigger effort to migrate Pytorch from Mypy to Pyre. The goal of this task for you is to gain comfort with the Python type system and the types of errors Pyre gives. Future Pysa project work and debugging builds on this foundation.

Development Environment Setup

Task Description

Fix the Pyre type checking errors in torch/_VF.pyi:

torch/_VF.pyi:86:84 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:101:139 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:103:136 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:105:163 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:107:160 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:429:25 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:451:44 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:453:61 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:496:44 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:498:61 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:614:40 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:616:62 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:618:40 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:620:62 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:666:53 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:674:99 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:676:96 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:678:126 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:680:123 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:681:78 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:682:98 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:683:49 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:701:48 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:703:57 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:754:28 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:759:86 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:765:97 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:776:28 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:817:43 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:819:60 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:821:75 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:823:89 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:825:40 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:827:57 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:833:99 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:835:141 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:903:42 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:905:59 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:907:73 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:911:76 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:913:95 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:972:39 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:978:105 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:998:59 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1000:81 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1015:62 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1017:84 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1023:59 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1025:81 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1040:63 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1042:82 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1065:65 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1067:87 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1085:201 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1113:119 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1124:53 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1126:50 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1128:80 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1130:77 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1131:77 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1166:43 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1192:112 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1194:109 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1196:85 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1198:82 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1200:53 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1202:50 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1204:80 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1206:77 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1207:77 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1213:92 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1215:103 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1217:113 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1219:110 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1221:86 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1223:83 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1225:54 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1227:51 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1229:81 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1231:78 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1232:78 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1234:85 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1236:53 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1293:32 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1341:39 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1343:91 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1345:66 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1347:110 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1349:85 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1407:68 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1410:75 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1428:91 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1438:121 Incompatible variable type [9]: out is declared to have type `Union[List[torch._tensor.Tensor], torch._tensor.Tensor, typing.Tuple[torch._tensor.Tensor, ...]]` but is used as type `None`.
torch/_VF.pyi:1440:58 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1443:58 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1507:54 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1509:51 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1511:81 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1513:78 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.
torch/_VF.pyi:1514:78 Incompatible variable type [9]: dtype is declared to have type `torch._C.dtype` but is used as type `None`.

Submitting a PR

We use the following linters internally, so to save everyone's time, please make sure you run the following linters locally and fix errors related to the files you modified before submitting a PR:

black && usort format . && flake8

To install the linters, you can run the following command:

pip install flake8 usort black==21.4b2