[2/N] Use "is" in python type comparison (#165142)

This is follow-up of #165037. It generally recommended to use `is/is not` to compare types. Therefore this series of changes apply this suggestion in the code base, and it aims to finally enabling related linter checks.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/165142
Approved by: https://github.com/albanD
This commit is contained in:
Yuanyuan Chen
2025-10-10 15:36:44 +00:00
committed by PyTorch MergeBot
parent 10a9fb641b
commit fb64da0791
57 changed files with 94 additions and 90 deletions

View File

@ -1251,7 +1251,7 @@ class BuiltinVariable(VariableTracker):
# Interaction between ndarray and tensors:
# We prefer the tensor op whenever there are tensors involved
if check_numpy_ndarray_args(args, kwargs) and not any(
type(arg) == variables.TensorVariable for arg in args
type(arg) is variables.TensorVariable for arg in args
):
proxy = tx.output.create_proxy(
"call_function",