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

Release 0.2.0 breaks compatibility with Poetry package manager #23

Closed
mazimi opened this issue May 28, 2020 · 5 comments
Closed

Release 0.2.0 breaks compatibility with Poetry package manager #23

mazimi opened this issue May 28, 2020 · 5 comments

Comments

@mazimi
Copy link

mazimi commented May 28, 2020

This issue is related to c473392

When adding the flake8-black package either via poetry add flake8-black or by adding it to pyproject.toml, you get this error:

[SolverProblemError]
Because no versions of flake8-black match >0.2.0,<0.3.0
 and flake8-black (0.2.0) depends on black (*), flake8-black (>=0.2.0,<0.3.0) requires black (*).
So, because no versions of black match *
 and <project-name> depends on flake8-black (^0.2.0), version solving failed.

If I pin to the prior version, poetry add flake8-black=0.1.2 I get the correct result:

% pip freeze
...
black==19.10b0
...

The recent change to allowing any release version of black prevents any pre-release version from being installed due to psf/black#517 that's been previously mentioned. IMO the correct behavior would be to specify the minimum compliant black pre-release version and allow the latest version to be installed by the package manager and be compliant with PEP 440. If there's a preference to keep the current behavior to support Pipenv users until pypa/pipenv#3928 is resolved - feel free to close this issue and it would be helpful to note that the current workaround for Poetry users is to add the following line in your pyproject.toml:

[tool.poetry.dev-dependencies]
...
black = { version = "*", allow-prereleases = true }
...

This is not ideal since sub-dependencies shouldn't need to be specified in pyproject.toml.

@peterjc
Copy link
Owner

peterjc commented May 28, 2020

Is is unfortunate that right now pipenv doesn't like flake8-black saying "black >= 19.3b0" (my issue #18/#21) while poetry doesn't like it saying just "black" (any version).

I agree, it would be nice if black dropped their pre-release tag because it is just causing trouble with many different packaging environments. This corner of PEP440 seems under tested, so something good is coming from this at least.

Do you know if there an equivalent poetry bug for it failing to pick the latest version of black in this circumstance? i.e. Their equivalent of pypa/pipenv#3928 - the closest I found was python-poetry/poetry#2413 which is a bit different as it isn't via a dependency.

In any case, I would strongly recommend your project explicitly pin the version of black yourself. With a large codebase even the recent versions of black introduce changes. As a poetry user, is that an acceptable workaround? If so, I can document that.

@peterjc
Copy link
Owner

peterjc commented May 28, 2020

Or, another workaround is just pin "flake8-black == 0.1.2" - and we can both hope the next Black release makes life easier ;)

@mazimi
Copy link
Author

mazimi commented May 28, 2020

I believe Poetry is compliant with PEP 440 and there is no bug to report with Poetry in this case - it's Pipenv that's not compliant.

It's not ideal to pin the version of black or flake8-black since it prevents updates. The best resolution for Poetry users is to explicitly allow pre-releases for only the black package by adding this to their pyproject.toml file:

[tool.poetry.dev-dependencies]
...
black = { version = "*", allow-prereleases = true }

This has the benefit of getting the latest flake8-black and black releases. As I mentioned, it's not ideal to specify sub-dependencies in pyproject.toml but it's the least painful solution that satisfies most users.

Thanks again for your work on this plugin, it simplifies workflow and CI. 🙏

@peterjc
Copy link
Owner

peterjc commented May 28, 2020

I would expect poetry to take the latest version of black in this context, but I think we'd both agree PEP440 could be much clearer on this.

While I suggest pinning black for stability, if you keep on top of it having the latest black is also viable - I try to do that with my own projects.

I think I need to add something to the flake8-black documentation, although I would rather point at some black documentation for all the workarounds needed because they still only have pre-releases on PyPI.

peterjc added a commit that referenced this issue May 31, 2020
@peterjc
Copy link
Owner

peterjc commented May 31, 2020

I've put something in the README file, please don't hesitate to suggest any improvements (either here or on a new issue), but marking this as closed now. Thank you.

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

No branches or pull requests

2 participants