Skip to content

Missing type hints cause falsely detected return type #8829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
twsl opened this issue Dec 25, 2024 · 5 comments · May be fixed by #8830
Open

Missing type hints cause falsely detected return type #8829

twsl opened this issue Dec 25, 2024 · 5 comments · May be fixed by #8830

Comments

@twsl
Copy link

twsl commented Dec 25, 2024

🐛 Describe the bug

The return type is automatically assumed as BoundingBoxes | Any by pyright

@torch.compiler.disable
def wrap(wrappee, *, like, **kwargs):

This could easily be fixed

Versions

Collecting environment information...
PyTorch version: 2.5.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux 12 (bookworm) (x86_64)
GCC version: (Debian 12.2.0-14) 12.2.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.36

Python version: 3.11.10 (main, Sep 27 2024, 06:09:18) [GCC 12.2.0] (64-bit runtime)
Python platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.36
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      46 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             12
On-line CPU(s) list:                0-11
Vendor ID:                          GenuineIntel
Model name:                         12th Gen Intel(R) Core(TM) i7-1265U
CPU family:                         6
Model:                              154
Thread(s) per core:                 2
Core(s) per socket:                 6
Socket(s):                          1
Stepping:                           4
BogoMIPS:                           5375.88
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize flush_l1d arch_capabilities
Virtualization:                     VT-x
Hypervisor vendor:                  Microsoft
Virtualization type:                full
L1d cache:                          288 KiB (6 instances)
L1i cache:                          192 KiB (6 instances)
L2 cache:                           7.5 MiB (6 instances)
L3 cache:                           12 MiB (1 instance)
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==2.2.0
[pip3] nvidia-cublas-cu12==12.4.5.8
[pip3] nvidia-cuda-cupti-cu12==12.4.127
[pip3] nvidia-cuda-nvrtc-cu12==12.4.127
[pip3] nvidia-cuda-runtime-cu12==12.4.127
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.2.1.3
[pip3] nvidia-curand-cu12==10.3.5.147
[pip3] nvidia-cusolver-cu12==11.6.1.9
[pip3] nvidia-cusparse-cu12==12.3.1.170
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] pytorch-lightning==2.5.0.post0
[pip3] pytorchcocotools==0.0.0
[pip3] torch==2.5.1
[pip3] torchmetrics==1.6.0
[pip3] torchvision==0.20.1
[pip3] triton==3.1.0
[conda] Could not collect
@twsl
Copy link
Author

twsl commented Jan 31, 2025

Any chance to get the pr merged soon?

@NicolasHug
Copy link
Member

Thanks for the report @twsl - Just pasting my comment from #8830 (comment)

Sorry folks, I don't think I can merge this. Mypy is painful enough to please (and I'll probably have to disable it entirely anyway), but I just really don't have any bandwidth to support all type-checkers out there :/

@twsl
Copy link
Author

twsl commented Feb 19, 2025

@NicolasHug I really don't understand your comment tho, cause this would help dealing with mypy, regardless of other type-checkers, as the current implementation is lacking all type hints.

@NicolasHug
Copy link
Member

cause this would help dealing with mypy, regardless of other type-checkers

I wish it would be that simple, but it's not. Some type checkers are happy with some annotations, while others are not. For example, mypy fails on your PR: https://github.com/pytorch/vision/actions/runs/13437322523/job/37542714033?pr=8830

I'm really sorry, but I have no bandwidth to deal with different type checkers. In fact I don't recommend rely on torchvision's type annotations at all, because a lot of them are wrong. They exist for torchscript to work, but they are often pretty incorrect.

@twsl
Copy link
Author

twsl commented Feb 20, 2025

Well, I do understand and share your frustration with mypy. However, given that my PR provides the correct implementation of the typehints and they are valuable for torchscript and other causes, i think we should still strive to merge it. I'll try to figure out, if mypy's wrong behaviour can be fixed and hope you will reconsider then (edit: at least it passes now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants