Skip to content

iamomerm/python-pact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pact: Attribute Enforcement Metaclass for Python

Pact is a lightweight Python metaclass designed to enforce the presence and types of class attributes in subclasses
It helps you ensure that all subclasses implement the required attributes declared in the base class,
catching missing or mistyped attributes early with warnings and exceptions

Features

  • Enforce presence of specific class or instance attributes in subclasses
  • Type validation of annotated attributes
  • Raises PactException exception and emits warnings for missing or mismatched attributes

Installation

You can install this package via PIP: pip install python-pact

Usage

from pact import Pact


class Person(Pact):
    name: str
    age: int


class JohnDoe(Person):
    name = 'John Doe'
    age = 25


# This will raise PactException due to missing 'age':
class JaneDoe(Person):
    name = 'Jane Doe'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages