Float processed property raises TypeError incorrectly when iterable_allowed property is set
zacharyedwardbull opened this issue · comments
Zachary Bull commented
Steps to reproduce
Use pyproprop version 0.4.3 or 0.4.2
Example
For example see the following script:
from pyproprop import processed_property
class ExampleClass:
error_float = processed_property(
"error_float",
type=float,
iterable_allowed=True,
)
def __init__(self,
error_float):
self.error_float = error_float
this_will_error = ExampleClass(5.1)
5.1 is a valid float, however when the script is run, the following error is raised:
Traceback (most recent call last):
File "/Users/.../pyproproperror.py", line 15, in <module>
this_will_error = ExampleClass(5.1)
File "/Users/.../pyproproperror.py", line 13, in __init__
self.error_float = error_float
File "/Users/.../site-packages/pyproprop/processed_property.py", line 228, in prop
value = method(value, *args, **kwargs)
File "/Users/.../site-packages/pyproprop/processed_property.py", line 260, in check_expected_type
value = check_type(value, expected_type, name_str, optional,
File "/Users/.../site-packages/pyproprop/processed_property.py", line 299, in check_type
raise TypeError(msg)
TypeError: `error_float` must be a <class 'float'>, instead got a <class 'tuple'>.
Process finished with exit code 1
Now running the same script again, but with iterable_allowed=False, the script runs without issue.
Sam Brockie commented
Fixed in 0.4.4 release.