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

tomlkit 0.11.2 breaks installations with comments in classifiers #6135

Closed
3 tasks done
bjoernricks opened this issue Aug 8, 2022 · 6 comments
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@bjoernricks
Copy link

bjoernricks commented Aug 8, 2022

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

Hi,

the latest version of tomlkit (0.11.2) did break the installations of packages for us. See for example

https://github.com/greenbone/mattermost-notify/runs/7718791468?check_suite_focus=true
https://github.com/greenbone/autohooks/runs/7718595745?check_suite_focus=true
https://github.com/greenbone/python-gvm/runs/7718639778?check_suite_focus=true

The issue seems to be caused by a behavior change with tomlkit 0.11.2 in how comments are handled in arrays. Our pyproject.toml files contain a comment (for example https://github.com/greenbone/autohooks/blob/43a78279e19a696cc3f0dd378aa28e4f1f2a329d/pyproject.toml#L15). It seems shallow copying an array with a comment introduces a None value. This results in a failing sort at https://github.com/python-poetry/poetry-core/blob/1.0.8/poetry/core/packages/package.py#L291.

See the gist for a short script reproducing the behavior.

Please let me know if and how I can provide a PR to fix this issue. Not sure where it needs to be addressed.

Traceback:

  4  /usr/local/lib/python3.9/dist-packages/poetry/console/commands/install.py:80 in handle
       78│ 
       79│         try:
    →  80│             builder = EditableBuilder(self.poetry, self._env, self._io)
       81│         except ModuleOrPackageNotFound:
       82│             # This is likely due to the fact that the project is an application

  3  /usr/local/lib/python3.9/dist-packages/poetry/masonry/builders/editable.py:34 in __init__
       32│ class EditableBuilder(Builder):
       33│     def __init__(self, poetry, env, io):
    →  34│         super(EditableBuilder, self).__init__(poetry)
       35│ 
       36│         self._env = env

  2  /usr/local/lib/python3.9/dist-packages/poetry/core/masonry/builders/builder.py:92 in __init__
       90│         )
       91│ 
    →  92│         self._meta = Metadata.from_package(self._package)
       93│ 
       94│     @property

  1  /usr/local/lib/python3.9/dist-packages/poetry/core/masonry/metadata.py:66 in from_package
      64│             meta.license = package.license.id
      65│ 
    → 66│         meta.classifiers = package.all_classifiers
      67│ 
      68│         # Version 1.2

  TypeError

  '<' not supported between instances of 'NoneType' and 'String'

  at /usr/local/lib/python3.9/dist-packages/poetry/core/packages/package.py:291 in all_classifiers
      287│             classifiers.append(self.license.classifier)
      288│ 
      289│         classifiers = set(classifiers)
      290│ 
    → 291│         return sorted(classifiers)
      292│ 
      293│     @property
      294│     def urls(self):  # type: () -> Dict[str, str]
      295│         urls = {}
@bjoernricks bjoernricks added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 8, 2022
nichtsfrei added a commit to greenbone/ospd-openvas that referenced this issue Aug 8, 2022
@radoering
Copy link
Member

This might be a tomlkit issue. Since your repro script is independent of poetry, you can create an issue at tomlkit. Further, you could bisect which tomlkit commit introduces this regression and check if a fix for this change is possible.

@bjoernricks
Copy link
Author

It could be intended behavior in tomlkit and then I think it needs to be addressed in poetry-core.

@radoering
Copy link
Member

It could, but I can't imagine why it should be intended to insert None into an array when copying it. Maybe, copying is just not supported but on the other side it worked before. Until the opposite is confirmed, I would assume a bug in tomlkit. Best way to find out (apart from investigating the change), might be to create a bug report at tomlkit.

@radoering
Copy link
Member

python-poetry/tomlkit#221 seems to address this issue. Can you try tomlkit 0.11.3?

@bjoernricks
Copy link
Author

Thanks python-poetry/tomlkit#221 fixed the issue

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants