(file: clean_file_t)
Returns a tuple containing a file-like object and a close indicator
	
	This ensures the given file is opened and keeps track of files that should
	be closed after use (files that were not open prior to this function call).
	
	Raises
	------
	OSError
		Accessing the given file path failed
	
	Parameters
	----------
	file
		A filepath or file-like object that may or may not need to be
		opened
Returns a tuple containing a file-like object and a close indicator
	
	This ensures the given file is opened and keeps track of files that should
	be closed after use (files that were not open prior to this function call).
	
	Raises
	------
	OSError
		Accessing the given file path failed
	
	Parameters
	----------
	file
		A filepath or file-like object that may or may not need to be
		opened
Returns a tuple containing a file - like object and a close indicator This ensures the given file is opened and keeps track of files that should be closed after use ( files that were not open prior to this function call ) . Raises ------ OSError Accessing the given file path failed Parameters ---------- file A filepath or file - like object that may or may not need to be opened
def clean_file(file: clean_file_t) -> ty.Tuple[ty.IO[bytes], bool]:
	"""Returns a tuple containing a file-like object and a close indicator
	
	This ensures the given file is opened and keeps track of files that should
	be closed after use (files that were not open prior to this function call).
	
	Raises
	------
	OSError
		Accessing the given file path failed
	
	Parameters
	----------
	file
		A filepath or file-like object that may or may not need to be
		opened
	"""
	if isinstance(file, int):
		return os.fdopen(file, 'rb', closefd=False), True
	elif not hasattr(file, 'read'):
		file = ty.cast(path_t, file)  # Cannot be ty.IO[bytes] without `.read()`
		return open(file, 'rb'), True
	else:
		file = ty.cast(ty.IO[bytes], file)  # Must be ty.IO[bytes]
		return file, False
def clean_file ( file : clean_file_t ) -> ty . Tuple [ ty . IO [ bytes ] , bool ] : if isinstance ( file , int ) : return os . fdopen ( file , 'rb' , closefd = False ) , True elif not hasattr ( file , 'read' ) : file = ty . cast ( path_t , file ) # Cannot be ty.IO[bytes] without `.read()` return open ( file , 'rb' ) , True else : file = ty . cast ( ty . IO [ bytes ] , file ) # Must be ty.IO[bytes] return file , False