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

Replaced vendored toml with tomli #5678

Merged
merged 9 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/5678.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop old vendored toml library. Use stdlib tomllib or tomli instead.
11 changes: 8 additions & 3 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
from json.decoder import JSONDecodeError
from pathlib import Path

try:
import tomllib as toml
except ImportError:
from pipenv.vendor import tomli as toml

from pipenv.cmdparse import Script
from pipenv.environment import Environment
from pipenv.environments import Setting, is_in_virtualenv, normalize_pipfile_path
Expand Down Expand Up @@ -40,7 +45,7 @@
system_which,
)
from pipenv.utils.toml import cleanup_toml, convert_toml_outline_tables
from pipenv.vendor import click, plette, toml, tomlkit
from pipenv.vendor import click, plette, tomlkit
from pipenv.vendor.requirementslib.models.utils import get_default_pyproject_backend

try:
Expand Down Expand Up @@ -176,9 +181,9 @@ def __init__(self, python_version=None, chdir=True):
"name": "pypi",
}

default_sources_toml = f"[[source]]\n{toml.dumps(self.default_source)}"
default_sources_toml = f"[[source]]\n{tomlkit.dumps(self.default_source)}"
for pip_conf_index in pip_conf_indexes:
default_sources_toml += f"\n\n[[source]]\n{toml.dumps(pip_conf_index)}"
default_sources_toml += f"\n\n[[source]]\n{tomlkit.dumps(pip_conf_index)}"
plette.pipfiles.DEFAULT_SOURCE_TOML = default_sources_toml

# Hack to skip this during pipenv run, or -r.
Expand Down
7 changes: 6 additions & 1 deletion pipenv/utils/toml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from pipenv.vendor import toml, tomlkit
try:
import tomllib as toml
except ImportError:
from pipenv.vendor import tomli as toml

from pipenv.vendor import tomlkit


def cleanup_toml(tml):
Expand Down
6 changes: 5 additions & 1 deletion pipenv/vendor/dparse/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
from configparser import ConfigParser, NoOptionError
from pathlib import PurePath

try:
import tomllib as toml
except ImportError:
from pipenv.vendor import tomli as toml

from .errors import MalformedDependencyFileError
from .regex import HASH_REGEX

from .dependencies import DependencyFile, Dependency
from pipenv.patched.pip._vendor.packaging.requirements import Requirement as PackagingRequirement,\
InvalidRequirement
from . import filetypes
import pipenv.vendor.toml as toml
from pipenv.patched.pip._vendor.packaging.specifiers import SpecifierSet
from pipenv.patched.pip._vendor.packaging.version import Version, InvalidVersion
import json
Expand Down
6 changes: 5 additions & 1 deletion pipenv/vendor/dparse/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import re
import json
import tempfile
import pipenv.vendor.toml as toml
import os

try:
import tomllib as toml
except ImportError:
from pipenv.vendor import tomli as toml


class RequirementsTXTUpdater(object):
SUB_REGEX = r"^{}(?=\s*\r?\n?$)"
Expand Down
25 changes: 0 additions & 25 deletions pipenv/vendor/toml/__init__.py

This file was deleted.

Loading