GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `TypeError: 'NoneType' object is not iterable` in `_top_level_inferred ` · Issue #344 · python/importlib_metadata

TypeError: 'NoneType' object is not iterable in _top_level_inferred  #344

New issue
Copy link
New issue
Copy link
Closed
#345
Closed
TypeError: 'NoneType' object is not iterable in _top_level_inferred #344
#345
Copy link

Description

@harupy
harupy
opened on Aug 26, 2021
Issue body actions

Reposting #340 (comment) as an issue.

I'm observing importlib_metadata.packages_distributions() throw the following error:

  File "/opt/mlflow/mlflow/utils/requirements_utils.py", line 129, in <module>
    _MODULE_TO_PACKAGES = importlib_metadata.packages_distributions()
  File "/miniconda/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 1016, in packages_distributions
    for pkg in _top_level_declared(dist) or _top_level_inferred(dist):
  File "/miniconda/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 1026, in _top_level_inferred
    return {

https://github.com/mlflow/mlflow/runs/3428616955#step:5:7078

It looks like the line 1028 in _top_level_inferred tries to iterate on dist.files that can be None and then throws the error above:

importlib_metadata/importlib_metadata/__init__.py

Lines 1025 to 1030 in 15df009

def _top_level_inferred(dist):
return {
f.parts[0] if len(f.parts) > 1 else f.with_suffix('').name
for f in dist.files
if f.suffix == ".py"
}

https://docs.python.org/3/library/importlib.metadata.html#distribution-files says:

In the case where the metadata file listing files (RECORD or SOURCES.txt) is missing, files() will return None. The caller may wish to wrap calls to files() in always_iterable or otherwise guard against this condition if the target distribution is not known to have the metadata present.

Activity

  1. andersk commented on Aug 26, 2021

    @andersk
    andersk
    on Aug 26, 2021
    More actions

    I happened to fix this in #342 with:

         @property
    -    def files(self):
    +    def files(self) -> List[PackagePath]:
    …
    -        return file_lines and list(starmap(make_file, csv.reader(file_lines)))
    +        return list(starmap(make_file, csv.reader(file_lines))) if file_lines else []

    Although if the None return is documented, maybe a different fix is needed. (Edit: done.)

  2. andersk
    added a commit that references this issue on Aug 26, 2021

    _top_level_inferred: Handle dist.files being None

    This issue will close once commit 81cc147 is merged into the 'main' branch.
    81cc147
  3. jaraco commented on Aug 26, 2021

    @jaraco
    jaraco
    on Aug 26, 2021
    Member
    More actions

    I've yanked the 4.7.0 release from PyPI while I address the issue.

    Reacted by Harutaka Kawamura
  4. jaraco
    added a commit that references this issue on Aug 26, 2021

    Add test capturing failure. Ref #344.

    f00d5c3
  5. jaraco
    closed this as completedin #345on Aug 26, 2021
  6. halstead
    added a commit that references this issue on Oct 13, 2021

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    01eb9d4
  7. splitice
    added 2 commits that reference this issue on Oct 13, 2021

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    dfa5d09

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    2b379ae
  8. kraj
    added a commit that references this issue on Oct 13, 2021

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    6442db7
  9. armcc
    added a commit that references this issue on Oct 13, 2021

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    7f7ff4b
  10. splitice
    added 3 commits that reference this issue on Oct 14, 2021

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    1a828f0

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    655fe9a

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    272b149
  11. halstead
    added 2 commits that reference this issue on Oct 14, 2021

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    4272ca4

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

    21d72ac
  12. seambot
    added a commit that references this issue on Oct 14, 2021

    python3-importlib-metadata: upgrade 4.6.4 -> 4.8.1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.