Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Stereotype is a performance-focused Python 3.8+ library for providing a structure for your data and validating it. The models allow fast & easy conversion between primitive data and well-typed Python classes.
Stereotype is heavily influenced by the beauty of dataclasses and versatility of Schematics, while having much better performance - both in terms of CPU usage and memory footprint. While it wasn't an influence, it is somewhat similar to Pydantic, but also beats it in benchmarks and provides easier validation.
Stereotype supports Python 3.8 and above (future support for older versions of Python is highly unlikely) and has 100% test coverage.
bool
, int
, float
, str
, Optional[*]
List[*]
of any type or a Dict[*, *]
of atomic types to any typeModel
subclass fields, including recursive definitionsModel
subclass fields resolved using a string type
keyAny
serializable
fields - a property
present also in serialized dataModel
instance validation methodsNone
values from outputFull documentation of stereotype
from typing import Optional, List
from stereotype import Model, StrField, FloatField
class Movie(Model):
name: str
genre: str = StrField(choices=("Comedy", "Action", "Family", "Drama"))
ratings: Optional[float] = FloatField(min_value=1, max_value=10, default=None)
cast: List[CastMember] = []
class CastMember(Model):
name: str
movie = Movie({"name": "Monty Python and the Holy Grail", "genre": "Comedy", "ratings": 8.2})
movie.validate()
movie.cast.append(CastMember({"name": "John Cleese"}))
print(movie.serialize())
See the Tutorial for more examples with detailed explanations.
Please see the Contribution guide
FAQs
Models for conversion and validation of rich data structures.
We found that stereotype 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.