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

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

Closed
harupy opened this issue Aug 26, 2021 · 2 comments · Fixed by #345
Closed

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

harupy opened this issue Aug 26, 2021 · 2 comments · Fixed by #345

Comments

@harupy
Copy link

harupy commented Aug 26, 2021

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:

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.

@andersk
Copy link

andersk commented Aug 26, 2021

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.)

andersk added a commit to andersk/importlib_metadata that referenced this issue Aug 26, 2021
@jaraco
Copy link
Member

jaraco commented Aug 26, 2021

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

jaraco added a commit that referenced this issue Aug 26, 2021
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
kraj pushed a commit to YoeDistro/poky-old that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
armcc pushed a commit to lgirdk/poky that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 4272ca45d137b91ec368c94b3e0dbd7d56c616dd)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
seambot pushed a commit to seamapi/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 21d72ace8f9486bd1b478e28d53da64087d790fa)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 21d72ace8f9486bd1b478e28d53da64087d790fa)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 21d72ace8f9486bd1b478e28d53da64087d790fa)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
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 a pull request may close this issue.

3 participants