pschanely / CrossHair

An analysis tool for Python that blurs the line between testing and type systems.
Other
996 stars 47 forks source link

`repr(collections.namedtuple)` errors #267

Closed tybug closed 2 months ago

tybug commented 2 months ago

https://crosshair-web.org/?crosshair=0.1&python=3.8&gist=8790f5063a0735bce910f2d54c9a3943

Found while trying to get hypothesis cover tests running against hypothesis-crosshair (https://github.com/HypothesisWorks/hypothesis/issues/3914). I'm trying to get better at filing these in the proper place (as opposed to https://github.com/pschanely/hypothesis-crosshair), and learning a bit of crosshair internals in the process. Please correct me if I'm misusing crosshair here and this is a spurious report!

Hypothesis-crosshair reproducer, if relevant:

import collections
from hypothesis import strategies as st
from hypothesis import given, settings

NamedTupleClass = collections.namedtuple("Something", ["target"])

@given(st.builds(NamedTupleClass, target=st.integers()))
@settings(backend="crosshair")
def f(x):
    repr(x)
f()
pschanely commented 2 months ago

Confirmed this as a CrossHair issue. (and wow, you really ARE in the CrossHair guts!)

CrossHair wasn't handling the old-style "%" string formatting. But cpython's namedtuple implementation still uses it internally, so I suppose I'll have to at least make it not explode! Hopefully will have something today,

pschanely commented 2 months ago

Fixed in 0.0.59!