pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.24k stars 1.12k forks source link

Pylint complains functions in torch.linalg not callable. #9218

Open hzhangxyz opened 10 months ago

hzhangxyz commented 10 months ago

Bug description

"""
Test pytorch linalg module with pylint
"""

import torch

def my_qr_decomposition(tensor: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
    """
    My QR
    """
    tensor_q, tensor_r = torch.linalg.qr(tensor)
    return tensor_q, tensor_r

Configuration

No response

Command used

python -m pylint main.py "--generated-member=torch.*,torch.linalg.*"

Pylint output

************* Module main
main.py:12:25: E1102: torch.linalg.qr is not callable (not-callable)

-----------------------------------
Your code has been rated at 0.00/10

Expected behavior

It is expected that pylint knows torch.linalg.qr is callable

Pylint version

pylint 3.0.2
astroid 3.0.1
Python 3.11.5 (main, Aug 28 2023, 12:39:56) [GCC 11.4.0]

OS / Environment

github action, see details at https://github.com/hzhangxyz/test-pytorch-linalg-pylint/actions/runs/6761431449/job/18376293735 .

Note: pylint 2.17.7 works well in this examples.

Additional dependencies

pytorch==2.0.1+cpu
enrico-stauss commented 8 months ago

I'm experiencing the same with some of the torch functionals (torch.nn.functional.(pad|conv2d)).