Skip to content

Comments

fix: propagate SkyCoord descriptor AttributeError (swev-id: astropy__astropy-14096)#125

Open
casey-brooks wants to merge 1 commit intoastropy__astropy-14096from
fix/skycoord-attrerror-propagation-swev-14096
Open

fix: propagate SkyCoord descriptor AttributeError (swev-id: astropy__astropy-14096)#125
casey-brooks wants to merge 1 commit intoastropy__astropy-14096from
fix/skycoord-attrerror-propagation-swev-14096

Conversation

@casey-brooks
Copy link

Summary

  • ensure SkyCoord.__getattr__ performs a static descriptor check before falling back to dynamic frame logic so subclass properties surface their own AttributeError
  • add regression coverage for subclass descriptors, transform alias access, and frame attribute delegation

Reproduction / Observed Failure

import astropy.coordinates as coord

class custom_coord(coord.SkyCoord):
    @property
    def prop(self):
        return self.random_attr

c = custom_coord('00h42m30s', '+41d12m00s', frame='icrs')
c.prop

Observed prior to this change:

AttributeError: 'custom_coord' object has no attribute 'prop'

Verification Notes

  • transform alias access (e.g., SkyCoord.icrs) continues to round-trip
  • frame attribute delegation (e.g., SkyCoord.obstime) continues to expose frame metadata

Resolves #116.

@casey-brooks casey-brooks requested a review from a team December 27, 2025 20:52
@casey-brooks
Copy link
Author

Test & Lint Summary

  • LIBGCC_DIR=$(dirname $(gcc --print-file-name=libgcc_s.so)) ZLIB_DIR=/nix/store/4wdz42ns29ys6fm1xak68bnp51nxhd2s-zlib-1.3.1/lib LD_LIBRARY_PATH=$LIBGCC_DIR:$ZLIB_DIR SETUPTOOLS_USE_DISTUTILS=stdlib PYTHONPATH=. .venv/bin/pytest astropy/coordinates/tests/test_sky_coord.py -k 'subclass_property_attribute_error_propagates or transform_alias_access_unchanged or frame_attribute_delegation_unchanged'
    • 3 passed, 431 deselected
  • SETUPTOOLS_USE_DISTUTILS=stdlib PYTHONPATH=. .venv/bin/flake8 --extend-ignore=E501,E203 --per-file-ignores='astropy/coordinates/tests/test_sky_coord.py:F841,E731' astropy/coordinates/sky_coordinate.py astropy/coordinates/tests/test_sky_coord.py
    • no lint findings (ignored E501/E203 and legacy F/E rules already waived in this file)

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix correctly short-circuits SkyCoord.__getattr__ when a descriptor is defined on the class so subclass properties raise their own errors again. Regression tests hit the descriptor case plus the alias/frame delegation paths, so coverage looks good. Approving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants