Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
sortedcontainers-pydantic
Advanced tools
This package adds Pydantic support to sortedcontainers, a fast pure-Python library for sorted mutable collections.
It implements Pydantic's special methods on subclasses of sortedcontainer's SortedDict
, SortedList
, and SortedSet
classes so that you can use them with Pydantic's models, validation, and serialization. To use, simply import the respective class of the same name from sortedcontainers_pydantic
instead of from sortedcontainers
. Only Pydantic V2 is supported.
from pydantic import BaseModel, TypeAdapter
from sortedcontainers_pydantic import SortedList
class MyModel(BaseModel):
sorted_list: SortedList[int]
MyModel(sorted_list=[3, 1, 2])
#> MyModel(sorted_list=SortedList([1, 2, 3]))
MyModel.model_validate_json('{"sorted_list": [3, 1, 2]}')
#> MyModel(sorted_list=SortedList([1, 2, 3]))
MyModel(sorted_list=[3, 1, 2]).model_dump_json()
#> '{"sorted_list":[1,2,3]}'
TypeAdapter(SortedList).validate_python([3, 1, 2])
#> SortedList([1, 2, 3])
TypeAdapter(SortedList).validate_json("[3, 1, 2]")
#> SortedList([1, 2, 3])
Reproducible example created by reprexlite v0.5.0
sortedcontainers-pydantic is available on PyPI. You can install it with
pip install sortedcontainers-pydantic
FAQs
Pydantic support for the sortedcontainers package.
We found that sortedcontainers-pydantic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.