9595
9696
9797def _get_package_version (package_name : str ):
98- from importlib .metadata import PackageNotFoundError , version
98+ from importlib .metadata import PackageNotFoundError , version # noqa: PLC0415
9999
100100 try :
101101 package_version = version (package_name )
@@ -105,7 +105,7 @@ def _get_package_version(package_name: str):
105105
106106
107107def _get_package_root (package_name : str , directory_name : str | None = None ):
108- from importlib .metadata import PackageNotFoundError , distribution
108+ from importlib .metadata import PackageNotFoundError , distribution # noqa: PLC0415
109109
110110 root_directory_name = directory_name or package_name
111111 try :
@@ -167,10 +167,10 @@ def _get_nvidia_dll_paths(is_windows: bool, cuda: bool = True, cudnn: bool = Tru
167167
168168def print_debug_info ():
169169 """Print information to help debugging."""
170- import importlib .util
171- import os
172- import platform
173- from importlib .metadata import distributions
170+ import importlib .util # noqa: PLC0415
171+ import os # noqa: PLC0415
172+ import platform # noqa: PLC0415
173+ from importlib .metadata import distributions # noqa: PLC0415
174174
175175 print (f"{ package_name } version: { __version__ } " )
176176 if cuda_version :
@@ -227,7 +227,7 @@ def is_target_dll(path: str):
227227 target_keywords = ["cufft" , "cublas" , "cudart" , "nvrtc" , "curand" , "cudnn" , * target_keywords ]
228228 return any (keyword in path for keyword in target_keywords )
229229
230- import psutil
230+ import psutil # noqa: PLC0415
231231
232232 p = psutil .Process (os .getpid ())
233233
@@ -238,7 +238,7 @@ def is_target_dll(path: str):
238238
239239 if cuda_version :
240240 if importlib .util .find_spec ("cpuinfo" ) and importlib .util .find_spec ("py3nvml" ):
241- from .transformers .machine_info import get_device_info
241+ from .transformers .machine_info import get_device_info # noqa: PLC0415
242242
243243 print ("\n Device information:" )
244244 print (get_device_info ())
@@ -265,10 +265,10 @@ def preload_dlls(cuda: bool = True, cudnn: bool = True, msvc: bool = True, direc
265265 If directory is empty string (""), the search order: nvidia site packages, default DLL loading paths.
266266 If directory is a path, the search order: the directory, default DLL loading paths.
267267 """
268- import ctypes
269- import os
270- import platform
271- import sys
268+ import ctypes # noqa: PLC0415
269+ import os # noqa: PLC0415
270+ import platform # noqa: PLC0415
271+ import sys # noqa: PLC0415
272272
273273 if platform .system () not in ["Windows" , "Linux" ]:
274274 return
0 commit comments