Skip to content

E1102 “not-callable” false positive for torch.nn.functional.one_hot (alias, fully-qualified, and direct import) #10710

@Julfried

Description

@Julfried

Bug description

Bug description
Pylint incorrectly reports E1102: not-callable for torch.nn.functional.one_hot regardless of how it’s referenced:

via alias: from torch.nn import functional as F; F.one_hot(...)
fully qualified: torch.nn.functional.one_hot(...)
direct import: from torch.nn.functional import one_hot; one_hot(...)

Minimal example:
not_callable.py:

import torch
from torch.nn.functional import one_hot
from torch.nn import functional as F

if __name__ == "__main__":
    t0 = one_hot(torch.tensor([0, 1, 2]), num_classes=4)
    t1 = F.one_hot(torch.tensor([0, 1, 2]), num_classes=4)
    t2 = torch.nn.functional.one_hot(torch.tensor([0, 1, 2]), num_classes=4)

Command used

pylint .\not_callable.py

Pylint output

************* Module not_callable
not_callable.py:7:11: E1102: one_hot is not callable (not-callable)
not_callable.py:8:12: E1102: F.one_hot is not callable (not-callable)
not_callable.py:9:12: E1102: torch.nn.functional.one_hot is not callable (not-callable)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

Not raise an error in this case because it is clearly callable

Pylint version

Tried these versions:
pylint 3.3.9
astroid 3.3.11
Python 3.13.7 (main, Sep  2 2025, 14:16:00) [MSC v.1944 64 bit (AMD64)]

pylint 4.0.2
astroid 4.0.1
Python 3.13.7 (main, Sep  2 2025, 14:16:00) [MSC v.1944 64 bit (AMD64)]

OS / Environment

No response

Additional dependencies

torch==2.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triage 📥Just created, needs acknowledgment, triage, and proper labelling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions