use the standard library tomllib on sufficiently new python#2202
Merged
staticdev merged 1 commit intoPyCQA:mainfrom Dec 4, 2023
Merged
use the standard library tomllib on sufficiently new python#2202staticdev merged 1 commit intoPyCQA:mainfrom
staticdev merged 1 commit intoPyCQA:mainfrom
Conversation
staticdev
requested changes
Dec 1, 2023
isort/settings.py
Outdated
| if sys.version_info >= (3, 11): | ||
| import tomllib | ||
| else: | ||
| from ._vendored import tomli |
Collaborator
There was a problem hiding this comment.
Suggested change
| from ._vendored import tomli | |
| from ._vendored import tomli as tomllib |
this will not work.. you will probably need this to keep working with older versions
Contributor
Author
There was a problem hiding this comment.
Right... IIRC I started off by importing tomllib as tomli and then switched approaches (because that allows pyupgrade to drop all the compat code) but forgot to update both locations.
Will fix...
In python 3.11 it is no longer necessary to vendor (?) a toml implementation. The vendored one is now part of the standard library. Simply use that instead. Benefits include: - micro-optimization when using the isort library API in an application that already uses tomllib, to avoid reading yet another one from on-disk - seamless support for automatically dropping tomli once the minimum python version is upgraded, via tools such as pyupgrade - distributors who patch out isort to use the system tomli, do not actually have to package tomli for versions of python that have tomllib
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2202 +/- ##
==========================================
- Coverage 99.22% 99.15% -0.07%
==========================================
Files 38 38
Lines 3087 3089 +2
Branches 747 748 +1
==========================================
Hits 3063 3063
- Misses 14 15 +1
- Partials 10 11 +1 |
staticdev
approved these changes
Dec 4, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In python 3.11 it is no longer necessary to vendor (?) a toml implementation. The vendored one is now part of the standard library. Simply use that instead.
Benefits include: