Skip to content

Commit

Permalink
Don't try to transform default values.
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
jmcs committed Jun 12, 2017
1 parent e2e36e9 commit 88e5f4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions ecological/autoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ def get(self, wanted_type: WantedType) -> WantedType:
:param wanted_type: type to return
:return: value as wanted_type
"""
raw_value = os.environ.get(self.name, self.default)
if raw_value is _NO_DEFAULT:
raise AttributeError(f"Configuration error: '{self.name}' is not set.")
try:
raw_value = os.environ[self.name]
except KeyError:
if self.default is _NO_DEFAULT:
raise AttributeError(f"Configuration error: '{self.name}' is not set.")
else:
return self.default

try:
value = self.transform(raw_value, wanted_type)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from setuptools import setup, find_packages

VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_MINOR = 1
VERSION = '{VERSION_MAJOR}.{VERSION_MINOR}'.format_map(locals())

python_version_major, python_version_minor = (int(version) for version in platform.python_version_tuple()[:-1])
Expand Down

0 comments on commit 88e5f4c

Please sign in to comment.