Closed HannoSpreeuw closed 1 month ago
Probably some loose ends although all unit tests pass, since hatch run lint:mypy
yields
sourcefinder/utility/containers.py:55: error: Signatures of "__iadd__" and "__add__" are incompatible [misc]
sourcefinder/accessors/lofarhdf5image.py:9: error: Missing positional arguments "beam", "centre_ra", "centre_decl", "data", "freq_bw", "freq_eff", "pixelsize", "tau_time", "taustart_ts", "url", "wcs" in call to "__init__" of "DataAccessor" [call-arg]
sourcefinder/accessors/lofarhdf5image.py:62: error: "LofarHdf5Image" has no attribute "header" [attr-defined]
sourcefinder/accessors/fitsimageblob.py:45: error: Signature of "_get_header" incompatible with supertype "FitsImage" [override]
sourcefinder/accessors/fitsimageblob.py:45: note: Superclass:
sourcefinder/accessors/fitsimageblob.py:45: note: def _get_header(self, hdu_index: Any) -> Any
sourcefinder/accessors/fitsimageblob.py:45: note: Subclass:
sourcefinder/accessors/fitsimageblob.py:45: note: def _get_header(self, hdulist: Any, hdu_index: Any) -> Any
sourcefinder/accessors/fitsimageblob.py:48: error: Signature of "read_data" incompatible with supertype "FitsImage" [override]
sourcefinder/accessors/fitsimageblob.py:48: note: Superclass:
sourcefinder/accessors/fitsimageblob.py:48: note: def read_data(self, hdu_index: Any, plane: Any) -> Any
sourcefinder/accessors/fitsimageblob.py:48: note: Subclass:
sourcefinder/accessors/fitsimageblob.py:48: note: def read_data(self, hdulist: Any, hdu_index: Any, plane: Any) -> Any
Found 5 errors in 3 files (checked 30 source files)
The line
sourcefinder/accessors/lofarhdf5image.py:61: error: "LofarHdf5Image" has no attribute "header" [attr-defined]
from the mypy
output has to do with
def get_header(self):
# Preserved for API compatibility.
return self.header
Apparently not implemented yet.
Should not be solved as part of this PR.
The other mypy
complaints have been taken care of through commit d163f9b.
Allright.
So that means DataAccessor
has been adequately reimplemented, but the design of its derived classes may need improvements.
Following @suvayu on replacing DataAccessor by a dataclass. DataAccessor was inheriting from RequiredAttributesMetaclass. This way of enforcing required attributes seems too heavy machinery and the dataclass is a a lightweight solution.
Should also fix #53