-
Notifications
You must be signed in to change notification settings - Fork 10
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
support other data type than string, add some failsafes #5
base: master
Are you sure you want to change the base?
Conversation
To be honest I need to double check with the team. I believe we tried to go back to your original code, but I lost track now. Will get back to you asap |
partial formatting
add build files
this will allow duplicate paths but will also solve an issue with not appending already related paths
Merge without append
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some general notes about the code.
try: | ||
dependent_keys = re.findall("{(.+?)}", value) | ||
for dependency in dependent_keys: | ||
# Ignore direct references to itself because | ||
# we don't format with itself anyway | ||
if dependency == key: | ||
continue | ||
|
||
dependencies.append((key, dependency)) | ||
dependencies.append((key, dependency)) | ||
except Exception: | ||
dependencies.append((key, value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be a try..except? Doesn't make much sense to me.
That'd only occur if value
is not a string maybe? E.g. a number or None? But that basically means the env
isn't an "environment" so the input is already invalid to begin with? This should error. No?
if not isinstance(env[key], str): | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of values are you expected in the input env
. I'd say that anything that is not a string is not an "environment value" and thus is invalid input. That should not be continued but should raise an error. It means the input value is wrong.
Unless maybe we'd want to explicitly skip None values?
acre/lib.py
Outdated
except Exception: | ||
r_token = re.compile(r"({.*?})") | ||
matches = re.findall(r_token, s) | ||
f = s | ||
for m in matches: | ||
try: | ||
f = re.sub(m, m.format(**data), f) | ||
except KeyError: | ||
continue | ||
return f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we improve the Exception (e.g. more explicit; what exception should we capture?) and add a comment to the code as to what this is trying to solve? When should this exception occur?
… BASH_FUNCTIONs to exist in environment
Ignore values with invalid curly braces or other invalid characters in the formatting
Update from current pypeclub:master