For my work, I had to be able to specify utf-8 encoding for the ignore file.
Due to the current craziness about default file encoding, my solution was to do the same as is done in the configparser python standard module. That required a change to 2 lines-
def parse_gitignore(full_path, base_dir=None):
def parse_gitignore(full_path, base_dir=None, *, encoding=None):
and
with open(full_path) as ignore_file:
with open(full_path, encoding=encoding) as ignore_file: