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
Poetry pip shims fix and dropping py3.7 in the same release breaks isort on py3.7 without recourse #2083
Poetry pip shims fix and dropping py3.7 in the same release breaks isort on py3.7 without recourse #2083
Comments
+1 to this. We are also in the same dilemma. Would it be possible to do another release that fixes isort for py3.7? |
Looks like the release 5.12.0 has dropped support for 3.7 and this has put everyone using < 3.8 in dilemma. |
This also affects python 3.11 |
It also seems to affect Python 3.10 We have over 100 projects, each of which with their own Updating all of the projects would be pretty cumbersome. But without a fix we'll be confronted with the same notification mess tomorrow (and each day after). We can mitigate this by pinning an |
We are having issues throughout many repositories because of this problem as well on Python 3.11... |
@psdon @exhuma and @RobPasMue Can you confirm you are using the latest version of isort (5.12.0)? This issue should be fixed in that release, but is bundled with the project deprecating support for Python3.7. I was planning on making a hot fix for 3.7 with the workaround for the surprising breaking change from poetry, but if this is still happening with the fix in place on those newer versions more investigation will be needed. Is is possible all these Python3.10/3.11 projects have the old version of isort pinned, or need to run a |
That's true, I was pointing to 5.11.4 while using Python 3.11 - thanks for pointing it out @timothycrosley! That solved our issues =) |
@timothycrosley The projects are not running on Running This will be done, but we cannot do this quickly enough and I prefer to do this in a calm, controlled space. We have a shared CI pipeline which gives me some flexibility but the nature of The quickest thing we can do is to disable |
@exhuma best of luck on your approach to fix this! I really wish there was a way for me to safely retroactively fix the old release, but it simply isn't possible. The only project that could fix it for existing references to the old version would be the poetry project, where the incompatibility was introduced |
Here is a script that I will shim into our shared pipeline runs. It's far from ideal, but it allows us to go through our projects piece by piece while keeping the pipelines "green". For anyone else who needs this, feel free to use it. This script replaces all isort references with 5.12.0. So even newer versions of isort would be "downgraded" which is pretty bad. But it's a workaround. #!/usr/bin/env python
"""
Fix for https://github.com/PyCQA/isort/issues/2083
This script *modifies* ``.pre-commit-config.yaml`` and pins the isort version
to 5.12.0
This is a hacky workaround for the aforementioned GitHub issue. Considering
that this aggressively changes the revision number for ``isort`` this should
only be used as a workaround if no other solution is available.
It should also be removed as soon as it is no longer needed because this will
"undo" any upgrades to ``isort`` in repositories.
This script assumes to be run in a CI-pipeline. As such, it also assumes that
it can modify files with impunity as they will not be committed back to the
source-code and will be lost after CI pipeline cleanup. This is - in this case
- the intended behaviour.
--- LICENSE ------------------------------------------------------------------
Copyright 2023 Michel Albert
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from copy import deepcopy
from os.path import exists
from shutil import copyfile
from textwrap import dedent
from yaml import dump, safe_load
import yamlfix.services
source_file = ".pre-commit-config.yaml"
backup_file = f"{source_file}.bak"
if exists(backup_file):
raise FileExistsError(f"File {backup_file} already exists")
copyfile(source_file, backup_file)
with open(source_file, encoding="utf8") as fptr:
content = safe_load(fptr)
replacement_done = False
for repo in content.get("repos", []):
if repo["repo"] == "https://github.com/PyCQA/isort" and not repo["rev"].startswith(
"5.12"
):
original = deepcopy(repo)
repo["rev"] = "5.12.0"
template = dedent(
f"""\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Problematic isort version {original["rev"]} detected
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Replacing with pinned 5.12.0
This is a *temporary* fix. For more information see
https://github.com/PyCQA/isort/issues/2083
----------------------------------------------------------------
Original Config
{{original}}
----------------------------------------------------------------
New Config
{{new}}
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
"""
)
print(
template.format(
original=yamlfix.fix_code(dump(original)),
new=yamlfix.fix_code(dump(repo)),
)
)
print(f"Updating {repo} with pinned isort version")
print(f"Updated to {repo}")
replacement_done = True
with open(source_file, "w", encoding="utf8") as fptr:
output = yamlfix.services.fix_code(dump(content))
fptr.write(output) |
Any change to prod the poetry devs for this? As a member of the |
Closing this as I've fixed this for 3.7 as well with a hotfix: 5.11.5 |
CI is broken on main due to this isort issue, the root cause lies in an underlying incompatible change in Poetry. PyCQA/isort#2083
CI is broken on main due to this isort issue, the root cause lies in an underlying incompatible change in Poetry. PyCQA/isort#2083 With the upgrade to flake8 6, we ran into an issue with comments in the configuration file. Those comments are moved to their own lines above the config instead, see issue below. PyCQA/flake8#1756
CI is broken on main due to this isort issue, the root cause lies in an underlying incompatible change in Poetry. The new version of isort has dropped support for Python 3.7 so we bump CI to run on 3.11 instead (3.7 is EOL later this year anyway). PyCQA/isort#2083 With the upgrade to flake8 6, we ran into an issue with comments in the configuration file. Those comments are moved to their own lines above the config instead, see issue below. PyCQA/flake8#1756
CI is broken on main due to this isort issue, the root cause lies in an underlying incompatible change in Poetry. The new version of isort has dropped support for Python 3.7 so we bump CI to run on 3.11 instead (3.7 is EOL later this year anyway). PyCQA/isort#2083 With the upgrade to flake8 6, we ran into an issue with comments in the configuration file. Those comments are moved to their own lines above the config instead, see issue below. PyCQA/flake8#1756 Because of installation issues in the lint step, installation is altered to only installed pre-commit which handles its own dependencies anyway.
See [CI error][1]: ```text RuntimeError: The Poetry configuration is invalid: - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$' ``` See [isort issues referencing `pip-shims`](PyCQA/isort#2083) for more details. [1]: https://github.com/connelldave/botocove/actions/runs/4120906018/jobs/7116097629
Update isort to 5.11.5 due to PyCQA/isort#2083 Note 5.12.0 is out but has already dropped support for python 3.7
Update isort to 5.11.5 due to PyCQA/isort#2083 Note 5.12.0 is out but has already dropped support for python 3.7
Update isort to 5.11.5 due to PyCQA/isort#2083 Note 5.12.0 is out but has already dropped support for python 3.7
The pre-commit shows an error in isort hook as follows. RuntimeError: The Poetry configuration is invalid This can be fixed by upgrading isort rev to 5.11.5 so this patch changes the version to fix it. In addition, apply changes from isort 5.11.5 to make pre-commit happy. Link: PyCQA/isort#2083 (comment) Signed-off-by: Honggyu Kim <honggyu.kp@gmail.com>
The pre-commit shows an error in isort hook as follows. RuntimeError: The Poetry configuration is invalid This can be fixed by upgrading isort rev to 5.11.5 so this patch changes the version to fix it. In addition, apply changes from isort 5.11.5 to make pre-commit happy. Link: PyCQA/isort#2083 (comment) Signed-off-by: Honggyu Kim <honggyu.kp@gmail.com>
Bumping to isort 5.11.5 fixes a bug with Poetry. See this comment: PyCQA/isort#2083 (comment)
Update isort to 5.11.5 due to PyCQA/isort#2083 Note 5.12.0 is out but has already dropped support for python 3.7
isort v5.10.1 present compatibility issues in some environments (see PyCQA/isort#2083 (comment)). isort v5.12.0 seems to solve the issue. Change-Id: Ie0d10567a9d281b211ef47f50acdd53ab55e9b6f Reviewed-on: https://forge.frm2.tum.de/review/c/frm2/nicos/nicos/+/30758 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Jonas Petersson <jonas.petersson@ess.eu> Reviewed-by: Jens Krueger <jens.krueger@frm2.tum.de>
… package described here PyCQA/isort#2083
Setting up the pre-commit hooks fails due to a bug in isort (see: PyCQA/isort#2083). This commit updates the version to 5.12.0 where this bug was fixed.
Setting up the pre-commit hooks fails due to a bug in isort (see: PyCQA/isort#2083). This commit updates the version to 5.12.0 where this bug was fixed.
The following PRs were bundled in 5.12.0
If I understand this correctly, anyone using isort on py3.7 does not get the poetry fix. Should there have been an intermediary release before
5.12.0
to cover this case ?The text was updated successfully, but these errors were encountered: