from typing import Union
from pathlib import Path
from typing import List


def readfile(contents: Union[str, Path]) -> List[str]:
	"""
		Takes a file path or the contents of a file and attemts to split it into lines.
	Parameters
	----------
	contents: Union[str, Path]

	Returns
	-------
	List[str]
		The lines in the file.

	"""
	if not isinstance(contents, str):
		contents = contents.read_text()
	lines = contents.split('\n')  # Use this instead of splitlines sine splitlines sometimes doesn't work right.
	# Remove any whitespace to the left and right of the contents in the line. This should avaid issues with extra whitespace padding on the lines.
	clean_lines = [l.strip() for l in lines]
	# Remove empty lines
	nonempty_lines = [l for l in clean_lines if l]
	return nonempty_lines