Skip to content

Commit

Permalink
Bump vendored version of plette to v0.3.0
Browse files Browse the repository at this point in the history
This version removes Python2 support. Partial fix for #5187.
  • Loading branch information
oz123 committed Sep 7, 2022
1 parent 7407087 commit 9ccbbca
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pipenv/vendor/plette/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Lockfile", "Pipfile",
]

__version__ = '0.2.3'
__version__ = '0.3.0'

from .lockfiles import Lockfile
from .pipfiles import Pipfile
18 changes: 6 additions & 12 deletions pipenv/vendor/plette/lockfiles.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from __future__ import unicode_literals

import json
import numbers

try:
import collections.abc as collections_abc
except ImportError:
import collections as collections_abc
import collections.abc as collections_abc

import pipenv.vendor.six as six

from .models import DataView, Meta, PackageCollection

Expand All @@ -28,14 +22,14 @@ def __init__(self):

def encode(self, obj):
content = super(_LockFileEncoder, self).encode(obj)
if not isinstance(content, six.text_type):
if not isinstance(content, str):
content = content.decode("utf-8")
content += "\n"
return content

def iterencode(self, obj):
for chunk in super(_LockFileEncoder, self).iterencode(obj):
if not isinstance(chunk, six.text_type):
if not isinstance(chunk, str):
chunk = chunk.decode("utf-8")
yield chunk
yield "\n"
Expand All @@ -53,15 +47,15 @@ def iterencode(self, obj):
def _copy_jsonsafe(value):
"""Deep-copy a value into JSON-safe types.
"""
if isinstance(value, six.string_types + (numbers.Number,)):
if isinstance(value, (str, numbers.Number)):
return value
if isinstance(value, collections_abc.Mapping):
return {six.text_type(k): _copy_jsonsafe(v) for k, v in value.items()}
return {str(k): _copy_jsonsafe(v) for k, v in value.items()}
if isinstance(value, collections_abc.Iterable):
return [_copy_jsonsafe(v) for v in value]
if value is None: # This doesn't happen often for us.
return None
return six.text_type(value)
return str(value)


class Lockfile(DataView):
Expand Down
6 changes: 2 additions & 4 deletions pipenv/vendor/plette/models/packages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pipenv.vendor.six as six

from .base import DataView


Expand All @@ -26,7 +24,7 @@ def validate(cls, data):
return super(Package, cls).validate({"__package__": data})

def __getattr__(self, key):
if isinstance(self._data, six.string_types):
if isinstance(self._data, str):
if key == "version":
return self._data
raise AttributeError(key)
Expand All @@ -39,7 +37,7 @@ def __getattr__(self, key):
def __setattr__(self, key, value):
if key == "_data":
super(Package, self).__setattr__(key, value)
elif key == "version" and isinstance(self._data, six.string_types):
elif key == "version" and isinstance(self._data, str):
self._data = value
else:
self._data[key] = value
4 changes: 1 addition & 3 deletions pipenv/vendor/plette/models/scripts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import re
import shlex

import pipenv.vendor.six as six

from .base import DataView


Expand All @@ -23,7 +21,7 @@ class Script(DataView):

def __init__(self, data):
super(Script, self).__init__(data)
if isinstance(data, six.string_types):
if isinstance(data, str):
data = shlex.split(data)
self._parts = [data[0]]
self._parts.extend(data[1:])
Expand Down
5 changes: 1 addition & 4 deletions pipenv/vendor/plette/pipfiles.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from __future__ import unicode_literals

import hashlib
import json

import pipenv.vendor.six as six
import pipenv.vendor.tomlkit as tomlkit

from .models import (
Expand Down Expand Up @@ -84,7 +81,7 @@ def get_hash(self):
"develop": self._data.get("dev-packages", {}),
}
content = json.dumps(data, sort_keys=True, separators=(",", ":"))
if isinstance(content, six.text_type):
if isinstance(content, str):
content = content.encode("utf-8")
return Hash.from_hash(hashlib.sha256(content))

Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ parse==1.19.0
pexpect==4.8.0
pipdeptree==2.2.1
platformdirs==2.4.0
plette[validation]==0.2.3
plette[validation]==0.3.0
ptyprocess==0.7.0
pyparsing==3.0.9
python-dotenv==0.19.0
Expand Down

0 comments on commit 9ccbbca

Please sign in to comment.