ty icon indicating copy to clipboard operation
ty copied to clipboard

Member <anything> may be missing on module `torch.distributed`

Open arogozhnikov opened this issue 4 months ago • 3 comments

Summary

import torch.distributed as tdist

tdist.all_gather # complains on all ops I use: get_rank / get_world_size / ...

while this seemingly works

from torch.distributed import ... 

Version

ty 0.0.7

arogozhnikov avatar Dec 28 '25 02:12 arogozhnikov

I'm not sure what the issue is exactly but all other type checkers that I tested (Pylance, Pyrefly) don't raise the same diagnostic.

MichaReiser avatar Dec 29 '25 11:12 MichaReiser

We have already disabled possibly-unresolved-reference and possibly-missing-import by default, due to the likelihood of false positives when libraries do complex conditional imports. (The latter being disabled by default is I think the only reason from torch.distributed import ... shows no issue here.) So for consistency I think we should also disable possibly-missing-attribute by default, otherwise you get this weird inconsistency where the import version is fine but the attribute version is not.

carljm avatar Dec 29 '25 16:12 carljm

for consistency I think we should also disable possibly-missing-attribute by default, otherwise you get this weird inconsistency where the import version is fine but the attribute version is not.

We cannot do that without first tackling https://github.com/astral-sh/ty/issues/1656

AlexWaygood avatar Dec 29 '25 17:12 AlexWaygood