#4889·hypothesis

Unintended error message raised when using `data().map(pack=str)`

Author: MarcoGorelliCreated Sep 29, 2026Updated Sep 29, 2026
Labelslegibility

Spotted while investigating whether the Pyrefly type-checker could run on the hypothesis source code

python
from hypothesis import strategies as st

st.data().map(pack=str)
python-traceback
Traceback (most recent call last):
  File "/home/mgorelli/hypothesis-dev/t.py", line 3, in <module>
    st.data().map(pack=str)
    ~~~~~~~~~~~~~^^^^^^^^^^
TypeError: DataStrategy.map() got an unexpected keyword argument 'pack'

Based on the signature there having f instead of the usual pack as argument name, I don't think this was intentional

The intended error message was probably

python-traceback
Traceback (most recent call last):
  File "/home/mgorelli/hypothesis-dev/t.py", line 3, in <module>
    st.data().map(pack=str)
    ~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/mgorelli/hypothesis-dev/hypothesis/src/hypothesis/strategies/_internal/core.py", line 2486, in map
    self.__not_a_first_class_strategy("map")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/home/mgorelli/hypothesis-dev/hypothesis/src/hypothesis/strategies/_internal/core.py", line 2498, in __not_a_first_class_strategy
    raise InvalidArgument(
    ...<2 lines>...
    )
hypothesis.errors.InvalidArgument: Cannot call map on a DataStrategy. You should probably be using @composite for whatever it is you're trying to do.

Happy to make a PR to fix this (and to add Pyrefly to CI if you wish, so similar issues are averted in the future?)

Source: HypothesisWorks/hypothesis