Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed duck typing exception to: (ImportError, AttributeError) #7874

Merged
merged 5 commits into from
May 26, 2023

Conversation

vhaasteren
Copy link
Contributor

@vhaasteren vhaasteren commented May 25, 2023

As described in issue #7870, there is a name-collision with the astrophysics package pint-pulsar, which is used to do high-precision pulsar timing. That other package would get imported as pint, and an AttributeError is thrown because that imported package is not the expected package.

By generalizing the duck typing exception to catch an ImportError and an AttributeError, we catch such name-collisions. It fits the idea and goal of duck typing.

This PR is a single-line change

…ow checking for missing attributes in imported packages
@welcome
Copy link

welcome bot commented May 25, 2023

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

Copy link
Collaborator

@keewis keewis left a comment

Choose a reason for hiding this comment

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

looks good. You might want to add an entry to whats-new.rst, but otherwise I think we can merge.

@Illviljan Illviljan added the plan to merge Final call for comments label May 26, 2023
doc/whats-new.rst Outdated Show resolved Hide resolved
doc/whats-new.rst Outdated Show resolved Hide resolved
@TomNicholas TomNicholas enabled auto-merge (squash) May 26, 2023 15:52
@TomNicholas TomNicholas merged commit f45eb73 into pydata:main May 26, 2023
@welcome
Copy link

welcome bot commented May 26, 2023

Congratulations on completing your first pull request! Welcome to Xarray! We are proud of you, and hope to see you again! celebration gif

dstansby pushed a commit to dstansby/xarray that referenced this pull request Jun 28, 2023
…ta#7874)

* Changed duck typing exception to (ImportError, AttributeError) to allow checking for missing attributes in imported packages

* Updated whats-new.rst with the duck typing exception catch update of PR 7874.

* Remove accidental url in whats-new

* Issue number in whats-new.rst

---------

Co-authored-by: Tom Nicholas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Name collision with Pulsar Timing package 'PINT'
4 participants