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

vendor: bump plette to 0.4.4 #5539

Merged
merged 2 commits into from
Dec 16, 2022
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/5539.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump plette version to 0.4.4
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.4.2'
__version__ = '0.4.4'

from .lockfiles import Lockfile
from .pipfiles import Pipfile
24 changes: 24 additions & 0 deletions pipenv/vendor/plette/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
A simple entry point which can be use to test Pipfiles

e.g.

python -m plette -f examples/Pipfile.valid.list
python -m plette -f examples/Pipfile.valid.editable
# throws exception
python -m plette -f examples/Pipfile.invalid.list

"""
from pipenv.vendor.plette import Pipfile

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-f", "--file", help="Input file")

args = parser.parse_args()

dest = args.file

with open(dest) as f:
pipfile = Pipfile.load(f)
8 changes: 7 additions & 1 deletion pipenv/vendor/plette/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
from .sources import Source

from .sections import (
Meta, Requires, PackageCollection, ScriptCollection, SourceCollection,
Meta,
Requires,
PackageCollection,
Pipenv,
PipfileSection,
ScriptCollection,
SourceCollection,
)
17 changes: 16 additions & 1 deletion pipenv/vendor/plette/models/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class Package(DataView):
def validate(cls, data):
# HACK: Make this validatable for Cerberus. See comments in validation
# side for more information.
return super(Package, cls).validate({"__package__": data})
super(Package, cls).validate({"__package__": data})
if isinstance(data, dict):
PackageSpecfiers.validate({"__specifiers__": data})

def __getattr__(self, key):
if isinstance(self._data, str):
Expand All @@ -41,3 +43,16 @@ def __setattr__(self, key, value):
self._data = value
else:
self._data[key] = value

class PackageSpecfiers(DataView):
# TODO: one could add here more validation for path editable
# and more stuff which is currently allowed and undocumented
__SCHEMA__ = {
"__specifiers__": {
"type": "dict",
"schema":{
"version": {"type": "string"},
"extras": {"type": "list"},
}
}
}
18 changes: 18 additions & 0 deletions pipenv/vendor/plette/models/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ def python_full_version(self):
"sources": SourceCollection,
}

class PipfileSection(DataView):

"""
Dummy pipfile validator that needs to be completed in a future PR
Hint: many pipfile features are undocumented in pipenv/project.py
"""

@classmethod
def validate(cls, data):
pass

class Meta(DataView):
"""Representation of the `_meta` section in a Pipfile.lock."""
Expand Down Expand Up @@ -119,3 +129,11 @@ def sources(self):
@sources.setter
def sources(self, value):
self["sources"] = value


class Pipenv(DataView):
"""Represent the [pipenv] section in Pipfile"""

__SCHEMA__ = {
"allow_prereleases": {"type": "boolean", "required": False},
}
10 changes: 8 additions & 2 deletions pipenv/vendor/plette/pipfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pipenv.vendor.tomlkit as tomlkit

from .models import (
DataView, Hash, Requires,
DataView, Hash, Requires, PipfileSection, Pipenv,
PackageCollection, ScriptCollection, SourceCollection,
)

Expand All @@ -15,6 +15,8 @@
"dev-packages": PackageCollection,
"requires": Requires,
"scripts": ScriptCollection,
"pipfile": PipfileSection,
"pipenv": Pipenv
}

DEFAULT_SOURCE_TOML = """\
Expand All @@ -24,7 +26,6 @@
verify_ssl = true
"""


class Pipfile(DataView):
"""Representation of a Pipfile.
"""
Expand All @@ -42,6 +43,11 @@ def validate(cls, data):
continue
klass.validate(data[key])

package_categories = set(data.keys()) - set(PIPFILE_SECTIONS.keys())

for category in package_categories:
PackageCollection.validate(data[category])

@classmethod
def load(cls, f, encoding=None):
content = f.read()
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dparse==0.6.2
markupsafe==2.0.1
pexpect==4.8.0
pipdeptree==2.3.1
plette[validation]==0.4.2
plette[validation]==0.4.4
ptyprocess==0.7.0
pyparsing==3.0.9
python-dotenv==0.19.0
Expand Down