Skip to content

pytorch-efficiency-lints does not work #4062

Description

@dillydill123

Describe the Bug

The pytorch-efficiency-lints option does not appear to do anything.

pyrefly.toml:

preset = "strict"
pytorch-efficiency-lints = true

errors = {
    pytorch-efficiency-lint-cuda-call = "error",
    pytorch-efficiency-lint-item-call = "error",
    pytorch-efficiency-lint-print-tensor = "error",
    pytorch-efficiency-lint-redundant-to-call = "error",
}

example.py:

import torch

def f(x: torch.Tensor) -> None:
    y = x.cuda()
    v = x.item()
    print(x)
    device = torch.device("cuda")
    w = torch.zeros(3, 4).to(device)

Running the following produces no errors.

$ pyrefly check --config pyrefly.toml example.py 
 INFO 0 errors

I also tried through CLI to see if it's a config issue:

$ pyrefly check --preset all --pytorch-efficiency-lints true --error pytorch-efficiency-lint-cuda-call example.py 
 INFO 0 errors

Apologies if I'm doing something wrong. How do I enable these checks?

Sandbox Link

No sandbox due to torch requirement.

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions