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

Feature/issue 1330 #1364

Merged
merged 4 commits into from May 18, 2018
Merged

Feature/issue 1330 #1364

merged 4 commits into from May 18, 2018

Conversation

seawolf42
Copy link
Contributor

@seawolf42 seawolf42 commented May 15, 2018

Summary of changes

Add __dir__() implementation to pkg_resources.Distribution() that includes the attributes in the _provider instance variable.

Closes #1330

Pull Request Checklist

  • Changes have tests
  • News fragment added in changelog.d. See documentation for details


if not hasattr(object, '__dir__'):
# python 2.7 not supported
del __dir__
Copy link
Contributor

Choose a reason for hiding this comment

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

Python 2.7 doesn't provide a default implementation of __dir__, but it'll use one in dir() if present. I found a pretty thorough cross-version solution on StackOverflow for making sure a functional base __dir__ is inherited; you'd probably only need a subset of that implementation to handle this particular case.

Copy link
Member

Choose a reason for hiding this comment

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

I'd be inclined to adopt that implementation for backward compatibility if it were published in six. Then I'd trust that it's hardened and supported. Otherwise, I'd rather not adopt that code for the marginal benefit it would provide. Still, good reference.

@seawolf42
Copy link
Contributor Author

@jmbowman not opposed to implementing that, but in conversations with @jaraco we felt this was a use case with minimal users as it:

  1. only applies to python 2.7
  2. is (AFAIK) only used manually in the python shell, not expected to be used in an automated fashion

Thoughts?

@jmbowman
Copy link
Contributor

I'm ok with leaving it as is, just looks a little odd to (sometimes) delete a method immediately after it's defined.

@seawolf42
Copy link
Contributor Author

Totally agree... that was actually @jaraco 's suggestion and I'd never seen that syntax/approach before.

@jaraco jaraco merged commit 811c4fe into pypa:master May 18, 2018
@jaraco
Copy link
Member

jaraco commented May 18, 2018

Thanks for the feedback.

@seawolf42 seawolf42 deleted the feature/issue-1330 branch May 21, 2018 18:59
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.

None yet

3 participants