Skip to content

Commit

Permalink
Fixed TypeError when instantiating Artifact. (#78)
Browse files Browse the repository at this point in the history
* Fixed TypeError when instantiating Artifact.
  • Loading branch information
yeunga authored and andamian committed May 10, 2018
1 parent 2ccc782 commit 3e4c770
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions caom2/caom2/caom_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
from datetime import datetime

import six
from builtins import bytes, int
from builtins import bytes, int, str as newstr


__all__ = ['TypedList', 'TypedSet', 'TypedOrderedDict', 'ClassProperty']
Expand Down Expand Up @@ -190,18 +190,22 @@ def type_check(value, value_type, variable, override=None):
vtype = value_type
if value_type == int_32:
vtype = int
if value_type == newstr and isinstance(value, str):
vtype = str
if not isinstance(value, vtype) and value is not override:
if override is not False:
raise TypeError(
"Expected {} or {} for {}, received {}".format(vtype,
override,
variable,
type(value)))
"Expected {} or {} for {}, received {}".format(
vtype,
override,
variable,
type(value)))
else:
raise TypeError(
"Expected {} for {}, received {}".format(vtype,
variable,
type(value)))
"Expected {} for {}, received {}".format(
vtype,
variable,
type(value)))
return True


Expand Down
2 changes: 1 addition & 1 deletion caom2/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ edit_on_github = False
github_project = opencadc/caom2tools
install_requires = future lxml aenum
# version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
version = 2.3.5
version = 2.3.6


[entry_points]
Expand Down

0 comments on commit 3e4c770

Please sign in to comment.