Skip to content

Commit

Permalink
Fix the errors raised when None is passed to template filters
Browse files Browse the repository at this point in the history
  • Loading branch information
kianelbo authored and potiuk committed Aug 8, 2022
1 parent 63f2067 commit 79da21b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions airflow/templates.py
Expand Up @@ -45,23 +45,28 @@ class SandboxedEnvironment(_AirflowEnvironmentMixin, jinja2.sandbox.SandboxedEnv


def ds_filter(value):
return value.strftime('%Y-%m-%d')
if value is not None:
return value.strftime('%Y-%m-%d')


def ds_nodash_filter(value):
return value.strftime('%Y%m%d')
if value is not None:
return value.strftime('%Y%m%d')


def ts_filter(value):
return value.isoformat()
if value is not None:
return value.isoformat()


def ts_nodash_filter(value):
return value.strftime('%Y%m%dT%H%M%S')
if value is not None:
return value.strftime('%Y%m%dT%H%M%S')


def ts_nodash_with_tz_filter(value):
return value.isoformat().replace('-', '').replace(':', '')
if value is not None:
return value.isoformat().replace('-', '').replace(':', '')


FILTERS = {
Expand Down

0 comments on commit 79da21b

Please sign in to comment.