astropy / astropy/astropy

Remove list inheritance for HDUList ?

Open
#7,308 8 comments 2 reactions 0 assignees View on GitHub
io.fits Refactoring
Dominant language
Python
Stars
5.3k
Forks
2.2k
Avg merge
1d 18h
Merged PRs (30d)
74

Description

Following recent discussions about support of list methods in HDUList (#7284 #7282 #7186 #7236), I think it would be better to remove the list inheritance. Currently HDUList inherits (and expose in its API) several list methods that either do not work (because of lazy loading) or do not make sense at all (because first item must be a PrimaryHDU): `clear`, `extend`, `reverse`, `sort`, maybe others.
We could probably inherit `collections.abc.Sequence` instead, and maybe even `collections.abc.MutableSequence`, as most of its methods seems based on `__iter__` and `__getitem__` (which allows to respect the lazy loading idea, i.e. load HDUs only if really required).
Thoughts @MSeifert04 @drdavella ?

Contributor guide

Open the contributing guide

Research direction

Start by reading the HDUList implementation and the referenced discussions in issues #7284, #7282, #7186, and #7236. Review which inherited list methods conflict with lazy loading or the PrimaryHDU requirement, then determine the appropriate Sequence or MutableSequence behavior. Done should mean the API no longer exposes inappropriate list operations while preserving required HDUList access.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.