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
@seawolf42 seawolf42 force-pushed the seawolf42:feature/issue-1330 branch from 3d73711 to 1a90187 May 15, 2018

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

This comment has been minimized.

@jmbowman

jmbowman May 16, 2018
Contributor

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.

This comment has been minimized.

@jaraco

jaraco May 18, 2018
Member

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

@seawolf42 seawolf42 commented May 17, 2018

@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

@jmbowman jmbowman commented May 17, 2018

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

@seawolf42 seawolf42 commented May 17, 2018

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
4 checks passed
4 checks passed
@codecov
codecov/patch 100% of diff hit (target 81.45%)
Details
@codecov
codecov/project 82.22% (+0.76%) compared to e0fd60c
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jaraco
Copy link
Member

@jaraco jaraco commented May 18, 2018

Thanks for the feedback.

@seawolf42 seawolf42 deleted the seawolf42:feature/issue-1330 branch May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants