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

Removing tomlkit from poetry core #6616

Merged

Conversation

dimbleby
Copy link
Contributor

Extended version of #6562, companion to python-poetry/poetry-core#483

Updates poetry to work with poetry-core after tomlkit is removed from there.

@dimbleby dimbleby changed the title Removing tomli from poetry core Removing tomlkit from poetry core Sep 24, 2022
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch 2 times, most recently from 5a6adad to b01c5c0 Compare September 24, 2022 15:07
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch 3 times, most recently from 3904437 to 0acf0ee Compare October 7, 2022 21:02
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch from 0acf0ee to 1b399ec Compare October 12, 2022 10:12
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch 2 times, most recently from 54053a3 to bffc6dc Compare November 5, 2022 14:30
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch from bffc6dc to 8a57be6 Compare December 1, 2022 19:23
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch from 8a57be6 to 00bb10c Compare December 19, 2022 23:11
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch from 00bb10c to 454ca18 Compare February 5, 2023 15:16
@radoering radoering force-pushed the removing-tomli-from-poetry-core branch from 454ca18 to 7d913f9 Compare March 21, 2023 17:23
@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch from b998fc5 to 7d913f9 Compare March 21, 2023 19:20
@radoering
Copy link
Member

Eventually, making this PR backward compatible was easier than I thought first. This gives us a clear procedure for merging this PR and its companion and allows us to further run downstream tests against poetry's master in poetry-core after merging.

IMO (and I don't recall contrary opinions), there is no need for tomlkit in poetry-core since we do not (and probably will never) write toml files in core. Since tomli is included in Python 3.11 as tomllib, it makes sense to rely on it if it fulfills our needs, especially in poetry-core.

I'll try to do a thorough review at the end of the week (or next week) and if there are no objections by then move forward.

@dimbleby
Copy link
Contributor Author

making this PR backward compatible

nice. On the whole I'd prefer the world to be arranged so that such things weren't necessary (approximately: disentangle the pipelines, rely on version numbers to signal compatibility) but it's certainly helpful that this can be done now

IMO ... there is no need for tomlkit in poetry-core

agreed: apart from the pipeline awkwardness - apparently now addressed - I think this ought to be uncontroversial

thanks for reviving this one

@radoering
Copy link
Member

Poetry.file is probably used by some plugins, so I'd prefer not to change its type. Of course, its core equivalent can't return a TOMLFile anymore. However, we could rename it e.g. to pyproject_path in core.

@dimbleby
Copy link
Contributor Author

dimbleby commented Apr 1, 2023

Poetry.file is probably used by some plugins, so I'd prefer not to change its type. Of course, its core equivalent can't return a TOMLFile anymore. However, we could rename it e.g. to pyproject_path in core.

If we remove (rename) poetry.file then that's breaking for all the places that access poetry.file.

The evidence from poetry itself is that there are lots of places that get poetry.file and use it only as a Path (mostly wanting poetry.file.parent).

So I think this is not an improvement.

@radoering
Copy link
Member

If we remove (rename) poetry.file then that's breaking for all the places that access poetry.file.

That applies only to downstream projects that depend on poetry-core directly but not on poetry. I'm not sure that's even a use case. I'd expect that plugin developers will rely on poetry.poetry.Poetry (which should keep poetry.file) not on poetry.core.poetry.Poetry. IMO we might even do a major version bump of poetry-core, but I'd like to avoid a breaking change for plugin developers.

@dimbleby
Copy link
Contributor Author

dimbleby commented Apr 1, 2023

I'm not following, sorry!

Is the suggestion that

  • in poetry.core, rename poetry.file -> poetry.pyproject_path
  • in poetry, rename poetry.toml_file -> poetry.file
    ?

that will give up backwards compatibility in this MR (because poetry.core.file is no longer available).

or did you mean something else?

src/poetry/poetry.py Outdated Show resolved Hide resolved
@radoering
Copy link
Member

I think we were talking past each other? Sorry for being ambiguous. I hope the two in-code-comments (the first in the core PR) make my suggestion more clear?

@dimbleby
Copy link
Contributor Author

dimbleby commented Apr 1, 2023

I see the suggestion, but my point is that the poetry-core change will be breaking for poetry itself. ie we'll back either with pipelines temporarily broken while one but not the other is merged, or doing some more complicated dance of renames and releases to avoid that.

Did I misunderstand? is that your intention?

@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch from 18b3ecc to 6723772 Compare April 1, 2023 15:54
@radoering
Copy link
Member

I can't follow where it will be breaking for poetry itself. The only place in poetry where poetry.core.poetry.Poetry is used is to inherit from it. If we add the file property to poetry's Poetry class we can keep using it as before. It doesn't matter if poetry-core's Poetry class has the same file property (current state) or no file property at all (future), does it? (For backward compatibility we should use the file property and not the new pyproject_path property, which is only in the future poetry-core, but that's something I'm willing to do for now.)

@dimbleby
Copy link
Contributor Author

dimbleby commented Apr 1, 2023

it's breaking in the following places:

src/poetry/factory.py:59: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/factory.py:66: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/factory.py:85: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/masonry/builders/editable.py:109: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/masonry/builders/editable.py:115: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/masonry/builders/editable.py:136: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/masonry/builders/editable.py:148: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/masonry/builders/editable.py:155: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/masonry/builders/editable.py:169: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/masonry/builders/editable.py:251: error: "Poetry" has no attribute "file"  [attr-defined]
src/poetry/installation/pip_installer.py:229: error: "Path" has no attribute "path"  [attr-defined]
src/poetry/installation/executor.py:658: error: "Path" has no attribute "path"  [attr-defined]

@dimbleby
Copy link
Contributor Author

dimbleby commented Apr 1, 2023

I suppose these can be worked around with a some casts and hasattr and suchlike

@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch from 2531b0d to aa235b8 Compare April 1, 2023 16:45
@dimbleby
Copy link
Contributor Author

dimbleby commented Apr 1, 2023

Is it better? I dunno, it's different anyway

@radoering
Copy link
Member

On it's own it's just different but I hope it makes the transition transparent for plugin developers.

Maybe, we should do the same for PyProject for consistency?

  • in poetry: toml_file -> file
  • in core: file -> path

@dimbleby dimbleby force-pushed the removing-tomli-from-poetry-core branch 2 times, most recently from 08b1fce to e1ec6ae Compare April 2, 2023 12:29
@dimbleby
Copy link
Contributor Author

dimbleby commented Apr 2, 2023

Maybe, we should do the same for PyProject

sure

@radoering radoering force-pushed the removing-tomli-from-poetry-core branch from 68eaa17 to 8a0e573 Compare April 3, 2023 09:51
@radoering radoering merged commit c89e994 into python-poetry:master Apr 3, 2023
@dimbleby dimbleby deleted the removing-tomli-from-poetry-core branch April 3, 2023 11:10
adriangb pushed a commit to adriangb/poetry that referenced this pull request Apr 5, 2023
…there (python-poetry#6616)

Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com>
Copy link

github-actions bot commented Mar 3, 2024

This pull request 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 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants