jhtimmins commented on a change in pull request #8637:
URL: https://github.com/apache/airflow/pull/8637#discussion_r418110002
##########
File path: airflow/configuration.py
##########
@@ -188,25 +189,37 @@ def _validate(self):
for section, replacement in self.deprecated_values.items():
for name, info in replacement.items():
old, new, version = info
- if self.get(section, name, fallback=None) == old:
- # Make sure the env var option is removed, otherwise it
- # would be read and used instead of the value we set
- env_var = self._env_var_name(section, name)
- os.environ.pop(env_var, None)
-
- self.set(section, name, new)
- warnings.warn(
- 'The {name} setting in [{section}] has the old default
value '
- 'of {old!r}. This value has been changed to {new!r} in
the '
- 'running config, but please update your config before
Apache '
- 'Airflow {version}.'.format(
- name=name, section=section, old=old, new=new,
version=version
- ),
- FutureWarning
- )
+ current_value = self.get(section, name, fallback=None)
+ if self._using_old_value(old, current_value):
+ new_value = re.sub(old, new, current_value)
+ self._update_env_var(section=section, name=name,
new_value=new_value)
+ self._create_future_warning(name=name, section=section,
current_value=current_value, new_value=new_value, version=version)
self.is_validated = True
+ def _using_old_value(self, old, current_value):
+ pattern = re.compile(old)
Review comment:
@ashb I'm fine with that, but `re.sub` only supports a compiled pattern
object for the old value, not the new value. So it'll need to be.
`'task_runner': (re.compile(r'^BashTaskRunner\Z'), r'StandardTaskRunner',
'2.0'),`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]