Closed lsetiawan closed 1 year ago
There are pieces of the code that does type comparison using type(blah) == mytype. This now seem to fail during pre-commit.ci as seen in PR https://github.com/OSOceanAcoustics/echoregions/pull/119. The better solution when comparing type, use isinstance(blah, mytype).
type(blah) == mytype
isinstance(blah, mytype)
https://github.com/OSOceanAcoustics/echoregions/blob/25a451851a17b131a9112b2bca850ba0340d4cea/echoregions/regions2d/regions2d.py#L413-L419
https://github.com/OSOceanAcoustics/echoregions/blob/25a451851a17b131a9112b2bca850ba0340d4cea/echoregions/tests/test_r2d.py#L32-L37
Thanks for spotting this! @lsetiawan, will add this to my testing PR.
Overview
There are pieces of the code that does type comparison using
type(blah) == mytype
. This now seem to fail during pre-commit.ci as seen in PR https://github.com/OSOceanAcoustics/echoregions/pull/119. The better solution when comparing type, useisinstance(blah, mytype)
.Places with errors
https://github.com/OSOceanAcoustics/echoregions/blob/25a451851a17b131a9112b2bca850ba0340d4cea/echoregions/regions2d/regions2d.py#L413-L419
https://github.com/OSOceanAcoustics/echoregions/blob/25a451851a17b131a9112b2bca850ba0340d4cea/echoregions/tests/test_r2d.py#L32-L37