A package that contains some useful decorators for any case.
Project description
ExtraDecorators
This module introduces some handy decorators like @validatetyping.
@validatetyping
# Example 1: Applying to a function
@validatetyping
def add(x: int, y: int) -> int:
return x + y
result = add(5, 10) # Valid call
result = add(5, '10') # Invalid call, will raise an ValueError
# Example 2: Applying to a class
class Point:
@validatetyping
def __init__(self, x: int, y: int):
self.x = x
self.y = y
p = Point(3, 4) # Valid initialization
p = Point('3', 4) # Invalid initialization, will raise an ValueError
There are some more in there, but not documentet (WIP)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
extradecorators-0.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for extradecorators-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce37ece01fdba4e9d93c24be0577b0abced18866b071f7ea98c4233e11de930d |
|
MD5 | 764dbba0d05e29c2169996949509be8e |
|
BLAKE2b-256 | bf8b4a3791d0c0007dc8a1ac11025f22d4826c6e9af7753ddca401df152062c2 |