Skip to content

Commit bc78873

Browse files
jhrmnndanielhollas
authored andcommitted
fix config file search when stdin
1 parent cb25402 commit bc78873

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fprettify/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,10 +1929,10 @@ def str2bool(str):
19291929
else:
19301930
return None
19311931

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

0 commit comments

Comments
 (0)