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

pkg_resources: fix stub for get_metadata_lines #2776

Merged

Conversation

@ewjoachim
Copy link
Contributor

commented Jan 30, 2019

The corresponding code is:
https://github.com/pypa/setuptools/blob/8f82e5077e2d3aab14aa3da636f79d37ff6d7ed7/pkg_resources/__init__.py#L1415-L1416

    def get_metadata_lines(self, name):
        return yield_lines(self.get_metadata(name))

https://github.com/pypa/setuptools/blob/8f82e5077e2d3aab14aa3da636f79d37ff6d7ed7/pkg_resources/__init__.py#L2346-L2357

def yield_lines(strs):
    """Yield non-empty/non-comment lines of a string or sequence"""
    if isinstance(strs, six.string_types):
        for s in strs.splitlines():
            s = s.strip()
            # skip blank lines/comments
            if s and not s.startswith('#'):
                yield s
    else:
        for ss in strs:
            for s in yield_lines(ss):
                yield s

This should always yield strings, not lists of strings.

(Do you want me to do a single PR with #2775 ?)

@JelleZijlstra JelleZijlstra merged commit caefaa6 into python:master Feb 1, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@JelleZijlstra

This comment has been minimized.

Copy link
Collaborator

commented Feb 1, 2019

Thanks! Small, focused PRs are good, but with small changes like these it may be more efficient to merge the PRs—it's up to you.

@ewjoachim ewjoachim deleted the ewjoachim:pkg_resources_get_metadata_lines branch Feb 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.