Hello,
I am using typecheck 0.3.5
Python 2.5
Linux Ubuntu 8.10
I tried this example:
import typecheck
from typecheck import accepts
from typecheck.typeclasses import String, Number
@accepts(Number)
def f(a):
print a
if __name__ == "__main__":
f("error")
instead of getting a type exception the function is executed successfully.
Cheers
Tiago
Hi,
I have found a way to solve this.
I'm not sure it does not add another bug somewhere else but
it works for me.
In the file typeclasses.py, I have changed this:
### Number
####################################################
_numbers = [int, float, complex, long, bool]
try:
from decimal import Decimal
_numbers.append(Decimal)
del Decimal
except ImportError:
pass
del _numbers
to this:
from typecheck import IsOneOf
### Number
####################################################
try:
from decimal import Decimal
Number = IsOneOf(int, float, long, complex, Decimal)
del Decimal
except ImportError:
Number = IsOneOf(int, float, long, complex)
I will do the same for String, etc.
Regards,
Marc.