Skip to content

Fix config file search when stdin #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions fprettify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,10 +1929,10 @@ def str2bool(str):
else:
return None

def get_config_file_list(filename):
def get_config_file_list(start_dir):
"""helper function to create list of config files found in parent directories"""
config_file_list = []
dir = os.path.dirname(filename)
dir = start_dir
while True:
config_file = os.path.join(dir, '.fprettify.rc')
if os.path.isfile(config_file):
Expand Down Expand Up @@ -2095,7 +2095,8 @@ def build_ws_dict(args):
# reparse arguments using the file's list of config files
filearguments = arguments
if argparse.__name__ == "configargparse":
filearguments['default_config_files'] = ['~/.fprettify.rc'] + get_config_file_list(os.path.abspath(filename) if filename != '-' else os.getcwd())
filearguments['default_config_files'] = ['~/.fprettify.rc'] \
+ get_config_file_list(os.path.dirname(os.path.abspath(filename)) if filename != '-' else os.getcwd())
file_argparser = get_arg_parser(filearguments)
file_args = file_argparser.parse_args(argv[1:])
ws_dict = build_ws_dict(file_args)
Expand Down