Registry / serialization / plette

plette

JSON →
library2.2.1pypypi✓ verified 84d ago

Plette is a Python library that provides structured models for parsing, generating, and validating Pipfile and Pipfile.lock files. It allows developers to programmatically interact with project dependencies in a structured manner. The current version is 2.1.0, and it maintains a regular release cadence with significant updates, including a major version bump from v1 to v2.

pip install plette
INSTALL
IMPORT
SIG · PLETTE
P
plette
serializationpythonv2.2.1
Install
1.6s avg
Import
79ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.083s · 18.3MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.075s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Pipfile
from plette import Pipfile
import plette.Pipfile_deprecated
Directly import the class from the package for clarity and to avoid potential naming conflicts with the top-level 'plette' module.
Lockfile
from plette import Lockfile
import plette.Lockfile_util
Directly import the class from the package.

This quickstart demonstrates how to load Pipfile and Pipfile.lock content from strings using `io.StringIO`, access their structured properties, and then modify and dump a Pipfile back to a string. It shows how to retrieve the required Python version from Pipfile, list packages, and access specific dependency versions from Lockfile.

import io from plette import Pipfile, Lockfile # Example Pipfile content pipfile_content = ''' [[source]] url = "https://pypi.org/simple" verify_ssl = true name = "pypi" [packages] requests = "*" [dev-packages] pytest = "*" [requires] python_version = "3.8" ''' # Example Pipfile.lock content (simplified for demonstration) lockfile_content = ''' { "_meta": { "hash": { "sha256": "some_hash" }, "requires": { "python_version": "3.8" } }, "default": { "requests": { "hashes": [ "sha256:hash1", "sha256:hash2" ], "version": "==2.28.1" } }, "develop": { "pytest": { "hashes": [ "sha256:hash3", "sha256:hash4" ], "version": "==7.1.2" } } } ''' # Load Pipfile with io.StringIO(pipfile_content) as f: pipfile = Pipfile.load(f) print(f"Pipfile Python Version: {pipfile.requires.python_version}") print(f"Pipfile Packages: {list(pipfile.packages.keys())}") # Load Lockfile with io.StringIO(lockfile_content) as f: lockfile = Lockfile.load(f) print(f"Lockfile requests version: {lockfile.default['requests']['version']}") print(f"Lockfile meta hash: {lockfile._meta['hash']['sha256']}") # Modify and dump (Pipfile example) pipfile.packages['rich'] = '==12.0.0' with io.StringIO() as f: pipfile.dump(f) print("\nModified Pipfile content:") print(f.getvalue())
Debug
Known issues
gotchaAccessing missing sections or keys in Pipfile or Lockfile models directly (e.g., `pipfile.non_existent_section`) will raise `KeyError` or `AttributeError`.
fix
Use the `.get()` method or `try-except` blocks to handle potentially missing keys gracefully. For example: `pipfile.get('non_existent_section', {})`.
affects: All versions
deprecatedWhile canonical names like `pipfile.source` and `lockfile._meta` are still available, direct manipulation of the `_meta` section of a `Lockfile` is generally discouraged.
fix
Prefer higher-level `plette` APIs for modifications, if available, or regenerate the lockfile using `pipenv lock` if using Pipenv, to ensure integrity and correct hashing.
affects: v2.0.0+
breakingMajor version `2.0.0` was released. While specific migration notes for `plette` are not extensively documented, changes between major versions often involve API refinements. Users upgrading from v1.x may encounter breaking changes in how certain properties are accessed or how objects are constructed.
fix
Review your code for direct property access, especially for nested structures or alias usage. Consult the official `plette` GitHub repository for any unlisted breaking changes. Prioritize using official loading/dumping methods and avoid direct dictionary manipulation where possible.
affects: v1.x to v2.x
Errors
Common errors & fixes
AttributeError: 'Pipfile' object has no attribute 'missing_section'
Attempting to access a non-existent top-level section in a Pipfile object directly as an attribute.
fix
Use dictionary-style `.get()` method to safely access sections, providing a default value if the section might be missing. E.g., `pipfile.get('missing_section', {})`.
KeyError: 'some-package' when accessing lockfile.default['some-package']
The specified package 'some-package' is not found within the 'default' dependencies section of the loaded Lockfile.
fix
Verify the package name is correct and present in the `Pipfile.lock`. Use `lockfile.default.get('some-package')` to handle cases where the package might not exist without raising an error.
TypeError: argument of type 'Lockfile' is not iterable
Trying to iterate directly over a `Lockfile` object, which is not designed to be iterable.
fix
Access specific sections of the `Lockfile` (e.g., `lockfile.default`, `lockfile.develop`) and iterate over those dictionaries. For example, `for package, details in lockfile.default.items(): ...`.
Upgrade
Version history
2.2.1latest on PyPI · released Apr 29, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
2
Resources
plette — pip install plette · libregistry