Skip to content

Commit

Permalink
Merge pull request #104 from ntqr/patch-1
Browse files Browse the repository at this point in the history
Make pathlib object convertible to a 'Template'
  • Loading branch information
sampsyo committed Jul 12, 2020
2 parents 6ce26e9 + f9889ea commit a2417d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions confuse/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
except ImportError:
SUPPORTS_ENUM = False

try:
import pathlib
SUPPORTS_PATHLIB = True
except ImportError:
SUPPORTS_PATHLIB = False

if sys.version_info >= (3, 3):
from collections import abc
else:
Expand Down Expand Up @@ -625,6 +631,8 @@ def as_template(value):
return Number()
elif isinstance(value, float):
return Number(value)
elif SUPPORTS_PATHLIB and isinstance(value, pathlib.PurePath):
return Path(value)
elif value is None:
return Template(None)
elif value is REQUIRED:
Expand Down

0 comments on commit a2417d9

Please sign in to comment.