Skip to content

Multiplying a measure by itself without specifying the measurement attribute results in TypeError #40

@JackAtOmenApps

Description

@JackAtOmenApps
>>> from measurement.measures import Mass
>>> m = Mass(lb=135)
>>> print(m)
135 lb
>>> print(m*m)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/measurement/base.py", line 346, in __mul__
    return type(self)(value=value, unit=self.unit.org_name)
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/measurement/base.py", line 254, in __init__
    value = decimal.Decimal(value)
TypeError: conversion from Mass to Decimal is not supported

It seems like this should work and return 135 lb * 135 lb = 18,225 lb

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions