Commit 67ada30
authored
[stubtest] Check runtime availability of private types not marked
Currently, stubtest ignores symbols that are 1) private and 2) not
present at runtime. Private names are often used for stub-only
constructs (which we don't want stubtest to complain about), but they
can also denote actual private runtime types. Without other context,
it's often ambiguous which category a private names falls into. For
class definitions, we can make the intent explicit by decorating the
class with `@type_check_only`. Typeshed already does this for the most
part, but there's still quite a few cases of stub-only private types
that aren't marked `@type_check_only` (especially in older stubs).
Going forward, I think it could a good idea to make stubtest start
checking for `@type_check_only` on private types that are not available
at runtime.
A few special cases are needed to avoid false positives on types that
cannot be marked with `@type_check_only`, namely:
* NewType declarations
* TypedDicts with fields that are not valid identifiers (and therefore
need to use the functional syntax)
~This PR creates quite a few new errors on typeshed (\~100 in stdlib,
\~300 in third-party stubs), which we'll probably want to sift through
before merging this.~ As of this writing, all typeshed hits have been
fixed.@type_check_only (#19574)1 parent bdef6ef commit 67ada30
File tree
3 files changed
+125
-11
lines changed- docs/source
- mypy
- test
3 files changed
+125
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
365 | 371 | | |
366 | 372 | | |
367 | 373 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
| 374 | + | |
373 | 375 | | |
374 | 376 | | |
375 | 377 | | |
| |||
439 | 441 | | |
440 | 442 | | |
441 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
442 | 453 | | |
443 | 454 | | |
444 | 455 | | |
| |||
448 | 459 | | |
449 | 460 | | |
450 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
451 | 475 | | |
452 | 476 | | |
453 | 477 | | |
| |||
639 | 663 | | |
640 | 664 | | |
641 | 665 | | |
642 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
643 | 670 | | |
644 | 671 | | |
645 | 672 | | |
| |||
2308 | 2335 | | |
2309 | 2336 | | |
2310 | 2337 | | |
| 2338 | + | |
2311 | 2339 | | |
2312 | 2340 | | |
2313 | 2341 | | |
| |||
2404 | 2432 | | |
2405 | 2433 | | |
2406 | 2434 | | |
| 2435 | + | |
| 2436 | + | |
2407 | 2437 | | |
2408 | 2438 | | |
2409 | 2439 | | |
| |||
2500 | 2530 | | |
2501 | 2531 | | |
2502 | 2532 | | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
2503 | 2538 | | |
2504 | 2539 | | |
2505 | 2540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
255 | 256 | | |
256 | 257 | | |
257 | 258 | | |
258 | | - | |
| 259 | + | |
259 | 260 | | |
260 | 261 | | |
261 | 262 | | |
| |||
904 | 905 | | |
905 | 906 | | |
906 | 907 | | |
907 | | - | |
| 908 | + | |
908 | 909 | | |
| 910 | + | |
909 | 911 | | |
910 | 912 | | |
911 | 913 | | |
| |||
921 | 923 | | |
922 | 924 | | |
923 | 925 | | |
| 926 | + | |
924 | 927 | | |
925 | 928 | | |
926 | 929 | | |
| |||
936 | 939 | | |
937 | 940 | | |
938 | 941 | | |
| 942 | + | |
939 | 943 | | |
940 | 944 | | |
941 | 945 | | |
| |||
1245 | 1249 | | |
1246 | 1250 | | |
1247 | 1251 | | |
1248 | | - | |
| 1252 | + | |
1249 | 1253 | | |
1250 | 1254 | | |
1251 | 1255 | | |
| |||
1316 | 1320 | | |
1317 | 1321 | | |
1318 | 1322 | | |
| 1323 | + | |
1319 | 1324 | | |
1320 | 1325 | | |
1321 | 1326 | | |
| |||
1693 | 1698 | | |
1694 | 1699 | | |
1695 | 1700 | | |
| 1701 | + | |
1696 | 1702 | | |
1697 | 1703 | | |
1698 | 1704 | | |
| |||
1749 | 1755 | | |
1750 | 1756 | | |
1751 | 1757 | | |
| 1758 | + | |
| 1759 | + | |
1752 | 1760 | | |
1753 | 1761 | | |
1754 | 1762 | | |
| |||
2375 | 2383 | | |
2376 | 2384 | | |
2377 | 2385 | | |
2378 | | - | |
| 2386 | + | |
2379 | 2387 | | |
| 2388 | + | |
2380 | 2389 | | |
2381 | 2390 | | |
2382 | 2391 | | |
| |||
2796 | 2805 | | |
2797 | 2806 | | |
2798 | 2807 | | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
2799 | 2872 | | |
2800 | 2873 | | |
2801 | 2874 | | |
| |||
2812 | 2885 | | |
2813 | 2886 | | |
2814 | 2887 | | |
2815 | | - | |
| 2888 | + | |
2816 | 2889 | | |
| 2890 | + | |
2817 | 2891 | | |
2818 | 2892 | | |
2819 | 2893 | | |
| |||
0 commit comments