Skip to content
Draft
Show file tree
Hide file tree
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
17 changes: 14 additions & 3 deletions configargparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def parse(self, stream):
raise ConfigFileParserException(str(e)) from e
else:
result[k] = v
return result
return convert_all_to_str(result)

def get_syntax_description(self):
msg = (
Expand All @@ -678,6 +678,15 @@ def get_syntax_description(self):
return msg


def convert_all_to_str(data):
if isinstance(data, list):
return [convert_all_to_str(item) for item in data]
elif isinstance(data, dict):
return {k: convert_all_to_str(v) for k, v in data.items()}
else:
return str(data)


class CompositeConfigParser(ConfigFileParser):
"""
Createa a config parser composed by others `ConfigFileParser`s.
Expand All @@ -697,7 +706,7 @@ def parse(self, stream):
errors = []
for p in self.parsers:
try:
return p.parse(stream) # type: ignore[no-any-return]
return convert_all_to_str(p.parse(stream)) # type: ignore[no-any-return]
except Exception as e:
stream.seek(0)
errors.append(e)
Expand Down Expand Up @@ -1014,7 +1023,9 @@ def parse_known_args(
# parse each config file
for stream in reversed(config_streams):
try:
config_items = self._config_file_parser.parse(stream)
config_items = convert_all_to_str(
self._config_file_parser.parse(stream)
)
except ConfigFileParserException as e:
self.error(str(e))
finally:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def launch_http_server(directory):
"PyYAML",
"pytest",
"pytest-cov",
"pytest-subtests",
]


Expand Down
Loading
Loading