Skip to content

liormizr/strictclasses

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

strictclasses

Disclaimer: this is beta software, API is not stable.

This is a validation companion to dataclasses.

It adds the strict method to the dataclass to validate the types are correct. Usage:

from dataclasses import dataclass
from strictclasses import strict

@strict
@dataclass
class Foo:
    bar: int


f = Foo('3')
f.strict() # -> TypeError: bar is not an instance of <class 'int'>
from strictclasses import strictclass

@strictclass
class Foo:
    bar: int


f = Foo('3') # -> TypeError: bar is not an instance of <class 'int'>
f = Foo(3)
f.bar = 3.3 # -> TypeError: bar is not an instance of <class 'int'>

About

A strict companion for Python dataclasses

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%