Fix none-comparison (E711) warnings (#19745)

Signed-off-by: Xiaodong Ye <yeahdongcn@gmail.com>
This commit is contained in:
R0CKSTAR
2026-03-07 08:15:21 +08:00
committed by GitHub
parent 0c4f98ed4e
commit e818f8219a
6 changed files with 15 additions and 15 deletions

View File

@@ -86,7 +86,7 @@ class CustomAsyncHTTPXClient(httpx.AsyncClient):
def get_client(provider):
if provider not in "b10":
if os.getenv("OPENAI_API_KEY") == None:
if os.getenv("OPENAI_API_KEY") is None:
os.environ["OPENAI_API_KEY"] = "EMPTY"
return {
"oai": AsyncOpenAI(base_url="http://127.0.0.1:8000/v1/"),

View File

@@ -1321,7 +1321,7 @@ def _nvmlGetFunctionPointer(name):
libLoadLock.acquire()
try:
# ensure library was loaded
if nvmlLib == None:
if nvmlLib is None:
raise NVMLError(NVML_ERROR_UNINITIALIZED)
try:
_nvmlGetFunctionPointer_cache[name] = getattr(nvmlLib, name)
@@ -1629,7 +1629,7 @@ class nvmlClkMonStatus_t(Structure):
# On Windows with the WDDM driver, usedGpuMemory is reported as None
# Code that processes this structure should check for None, I.E.
#
# if (info.usedGpuMemory == None):
# if (info.usedGpuMemory is None):
# # TODO handle the error
# pass
# else:
@@ -2870,13 +2870,13 @@ def _LoadNvmlLibrary():
"""
global nvmlLib
if nvmlLib == None:
if nvmlLib is None:
# lock to ensure only one caller loads the library
libLoadLock.acquire()
try:
# ensure the library still isn't loaded
if nvmlLib == None:
if nvmlLib is None:
try:
if sys.platform[:3] == "win":
# cdecl calling convention
@@ -2902,7 +2902,7 @@ def _LoadNvmlLibrary():
nvmlLib = CDLL("libnvidia-ml.so.1")
except OSError as ose:
_nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
if nvmlLib == None:
if nvmlLib is None:
_nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
finally:
# lock is always freed

View File

@@ -380,7 +380,7 @@ class MambaPool:
def fork_from(self, src_index: torch.Tensor) -> Optional[torch.Tensor]:
dst_index = self.alloc(1)
if dst_index == None:
if dst_index is None:
return None
self.copy_from(src_index, dst_index)
return dst_index

View File

@@ -124,7 +124,7 @@ class TestNixlUnified(unittest.TestCase):
# Test get
retrieved2 = self.hicache.get(key, dst_addr, dst_len)
self.assertTrue(retrieved2 == None)
self.assertTrue(retrieved2 is None)
self.verify_tensors_equal(value, dst_tensor2)
def test_batch_set_get(self):
@@ -159,7 +159,7 @@ class TestNixlUnified(unittest.TestCase):
# Test batch get
retrieved2 = self.hicache.batch_get(keys, dst_addrs, dst_lens)
self.assertTrue(all(ret == None for ret in retrieved2))
self.assertTrue(all(ret is None for ret in retrieved2))
self.verify_tensor_lists_equal(values, dst_tensors2)
def test_mixed_operations(self):

View File

@@ -2065,12 +2065,12 @@ def get_device(device_id: Optional[int] = None) -> str:
return "cuda:{}".format(device_id)
if hasattr(torch, "xpu") and torch.xpu.is_available():
if device_id == None:
if device_id is None:
return "xpu"
return "xpu:{}".format(device_id)
if is_npu():
if device_id == None:
if device_id is None:
return "npu"
return "npu:{}".format(device_id)
@@ -2079,16 +2079,16 @@ def get_device(device_id: Optional[int] = None) -> str:
import habana_frameworks.torch.hpu # noqa: F401
if torch.hpu.is_available():
if device_id == None:
if device_id is None:
return "hpu"
return "hpu:{}".format(device_id)
except ImportError as e:
except ImportError:
raise ImportError(
"Habana frameworks detected, but failed to import 'habana_frameworks.torch.hpu'."
)
if is_musa():
if device_id == None:
if device_id is None:
return "musa"
return "musa:{}".format(device_id)

View File

@@ -68,7 +68,7 @@ def rpd_to_chrome_trace(
rangeStringMonitor = ""
min_time = connection.execute("select MIN(start) from rocpd_api;").fetchall()[0][0]
max_time = connection.execute("select MAX(end) from rocpd_api;").fetchall()[0][0]
if min_time == None:
if min_time is None:
raise Exception("Trace file is empty.")
print("Timestamps:")