Analyze Python code for correctness using symbolic execution and SMT solving to automatically find counterexamples for functions with type annotations and contracts.
86
A Python library providing utility functions that work with generic types and TypeVars. All functions include contracts that can be verified using symbolic execution.
@generates
from typing import TypeVar, Tuple, List, Union
T = TypeVar('T')
NumericT = TypeVar('NumericT', int, float)
def swap_pair(pair: Tuple[T, T]) -> Tuple[T, T]:
"""
Swaps the two elements in a pair tuple.
pre: len(pair) == 2
post: __return__[0] == pair[1] and __return__[1] == pair[0]
"""
pass
def process_numeric(value: NumericT, multiplier: NumericT) -> NumericT:
"""
Multiplies a numeric value by a multiplier of the same numeric type.
pre: isinstance(value, (int, float)) and isinstance(multiplier, (int, float))
post: isinstance(__return__, type(value))
"""
pass
def get_first(items: List[T]) -> T:
"""
Returns the first element from a non-empty list.
pre: len(items) > 0
post: __return__ == items[0]
"""
pass
def transform_list(items: List[T], default: T) -> List[T]:
"""
Transforms a list by replacing empty positions with a default value.
Returns a list of the same type.
pre: len(items) >= 0
post: len(__return__) == len(items)
post: all(isinstance(x, type(default)) for x in __return__)
"""
passProvides symbolic execution and contract verification capabilities for Python code.
Install with Tessl CLI
npx tessl i tessl/pypi-crosshair-toolevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10