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

Use tomllib instead of tomli on Python 3.11 #1377

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -20,7 +20,8 @@ development at the same time, such as 4.5.x and 5.0.
Unreleased
----------

Nothing yet.
- The ``toml`` extra no longer installs ``tomli`` on Python 3.11 (``tomllib``
is used instead)


.. _changes_633:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -11,6 +11,7 @@ Albertas Agejevas
Aleksi Torhamo
Alex Gaynor
Alex Groce
Alex Grönholm
Alex Sandro
Alexander Todorov
Alexander Walters
Expand Down
8 changes: 6 additions & 2 deletions coverage/tomlconfig.py
Expand Up @@ -6,6 +6,7 @@
import configparser
import os
import re
import sys

from coverage.exceptions import ConfigError
from coverage.misc import import_third_party, substitute_variables
Expand All @@ -14,8 +15,11 @@
# import_third_party will unload any module that wasn't already imported.
# tomli imports typing, and if we unload it, later it's imported again, and on
# Python 3.6, this causes infinite recursion.)
import typing # pylint: disable=unused-import, wrong-import-order
tomli = import_third_party("tomli")
if sys.version_info >= (3, 11):
import tomllib as tomli
else:
import typing # pylint: disable=unused-import, wrong-import-order
tomli = import_third_party("tomli")


class TomlDecodeError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -108,7 +108,7 @@ def better_set_verbosity(v):

extras_require={
# Enable pyproject.toml support.
'toml': ['tomli'],
'toml; python_version < "3.11"': ['tomli'],
},

# We need to get HTML assets from our htmlfiles directory.
Expand Down