Skip to content

Instantly share code, notes, and snippets.

View pschanely's full-sized avatar

Phillip Schanely pschanely

View GitHub Profile
@pschanely
pschanely / main.py
Created July 19, 2024 22:02
Shared via CrossHair Playground
from crosshair.core_and_libs import proxy_for_type, standalone_statespace
from pathlib import PurePath
from crosshair.core import NoTracing
from crosshair.libimpl.builtinslib import (LazyIntSymbolicStr, SymbolicBoundedIntTuple)
with standalone_statespace:
with NoTracing():
# Any of these definitions will exhibit the issue,
# because we don't really do anything with the string:
@pschanely
pschanely / main.py
Created July 19, 2024 21:23
Shared via CrossHair Playground
from crosshair.core_and_libs import proxy_for_type, standalone_statespace
from pathlib import PurePath
from crosshair.core import NoTracing
from crosshair.libimpl.builtinslib import (LazyIntSymbolicStr, SymbolicBoundedIntTuple)
with standalone_statespace:
with NoTracing():
symbolic = LazyIntSymbolicStr(
SymbolicBoundedIntTuple((1, 2, 3), "tempname")
)
@pschanely
pschanely / main.py
Created July 19, 2024 21:09
Shared via CrossHair Playground
import re
def f():
'''
post: True
'''
dict(foo=1)
@pschanely
pschanely / main.py
Created July 18, 2024 11:05
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created July 17, 2024 09:52
Shared via CrossHair Playground
import re
from typing import Optional
def parse_year(yearstring: str) -> Optional[int]:
'''
Something is wrong with this year parser! Can you guess what it is?
post: __return__ is None or 1000 <= __return__ <= 9999
'''
return int(yearstring) if re.match('[1-9][0-9][0-9][0-9]', yearstring) else None
@pschanely
pschanely / main.py
Created July 15, 2024 09:32
Shared via CrossHair Playground
from fractions import Fraction
def test(n1: int, n2: int) -> None:
'''
post: True
'''
assert n2 > 0
print(Fraction(n1, n2))
@pschanely
pschanely / main.py
Created July 15, 2024 03:54
Shared via CrossHair Playground
import typing
class Foo:
def __init__(self, values: list) -> None:
self._values = values
def fn(_: bool):
""" post: True """
return typing.get_type_hints(Foo)
@pschanely
pschanely / main.py
Created July 14, 2024 20:57
Shared via CrossHair Playground
def make_bigger(n: int) -> int:
'''
post: __return__ != 0
'''
return 2 * n + 10
@pschanely
pschanely / main.py
Created July 14, 2024 11:45
Shared via CrossHair Playground
import hashlib
def dohash(buf: bytes):
""" post: True """
return hashlib.sha256(buf)
@pschanely
pschanely / main.py
Created July 9, 2024 08:20
Shared via CrossHair Playground
import dataclasses
from typing import List
@dataclasses.dataclass
class AverageableQueue:
'''
A queue of numbers with a O(1) average() operation.
inv: self._total == sum(self._values)
'''
_values = []