In addition to the comments from @vnp, which I agree with, consider simplifying your argparse to something like:
import argparse
digests = { "md5": None, "sha1": None, "sha256": None}
def _get_arguments(args=None):
# Argument Parser for the overall function
parser = argparse.ArgumentParser(
description="Run hash sum functions on a file and return them.")
parser.add_argument('filepath',
help="Path to file to run sums on.")
parser.add_argument('--hashes',
nargs='*',
choices=digests,
default=["md5", "sha1"],
help="Hashes to be used. Default: md5, sha1")
return parser.parse_args(args)
print _get_arguments()
The choices of the hashes can use the dictionary of defined hashes @vnp recommended as well (No need for digests.keys() here, argparse does it correctly even when given a dictionary instead of a list).
I added the args parameter to allow interactive testing of this function.
$ python argparse_new.py file
Namespace(filepath='file', hashes=['md5', 'sha1'])
$ python argparse_new.py file --hashes md5
Namespace(filepath='file', hashes='md5')
$ python argparse_new.py file --hashes md5 sha256
Namespace(filepath='file', hashes=['md5', 'sha256'])
$ python argparse_new.py --hashes md5 sha256
usage: argparse_new.py [-h]
[--hashes [{sha256,sha1,md5} [{sha256,sha1,md5} ...]]]
filepath
argparse_new.py: error: too few arguments