Skip to content

[atheris] Add FuzzedDataProvider and re-export the public API from atheris - #16610

Merged
srittau merged 2 commits into
python:mainfrom
Culaii:atheris-fuzzed-data-provider
Nov 19, 2026
Merged

srittau merged 2 commits into
python:mainfrom
Culaii:atheris-fuzzed-data-provider

Conversation

@Culaii

@Culaii Culaii commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

atheris.FuzzedDataProvider was missing, and atheris.instrument_imports / instrument_func /
instrument_all / enabled_hooks were not re-exported from atheris/__init__.pyi, so all of
them were reported as missing attributes (cf. google/atheris#110).

This adds atheris/native.pyi (where FuzzedDataProvider, Setup, Fuzz, Mutate and
ALL_REMAINING live at runtime) and re-exports the public names from atheris.

Notes:

  • pybind11 signatures can't be introspected by stubtest, so the annotations follow the bindings
    and the C++ declarations; unnamed pybind11 arguments are positional-only (ConsumeUnicode is
    the only one bound with py::arg("count")).
  • PickValueInList takes list[_T]: the binding is py::list, and tuples are rejected at runtime.
  • Setup/Mutate become positional-only, matching the runtime (keyword calls raise TypeError).
  • The metaclass of FuzzedDataProvider is pybind11_builtins.pybind11_type; allowlisted as for
    hnswlib.Index.

Upstream: bindings,
declarations,
docs.

Prepared with Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

Add `atheris/native.pyi` (where `FuzzedDataProvider`, `Setup`, `Fuzz`, `Mutate` and
`ALL_REMAINING` live at runtime) and re-export the public names from `atheris/__init__.pyi`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit below.

Also, per our new policy, please use float | int in argument types where both types are accepted/possible. (The same for return types, where both are potentially returned, but that has always been the case.)

Comment thread stubs/atheris/atheris/native.pyi Outdated

def Setup(
args: Sequence[str],
test_one_input: Callable[[bytes], None],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is copied from before, but I assume the return type of test_one_input calls is just ignored? In this case object is preferred over None.

The test_one_input callback is held as std::function<void(py::bytes)>, so its
result is discarded: object rather than None. The ConsumeFloat*InRange bounds
are doubles, which pybind11 converts from int: float | int.
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit b55de66 into python:main Nov 19, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants