Skip to content

Commit f95933f

Browse files
authored
Restore atheris stubs (#15140)
1 parent 8d96801 commit f95933f

File tree

7 files changed

+121
-0
lines changed

7 files changed

+121
-0
lines changed

stubs/atheris/METADATA.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version = "2.3.*"
2+
upstream_repository = "https://github.com/google/atheris"
3+
partial_stub = true
4+
5+
[tool.stubtest]
6+
ignore_missing_stub = true
7+
# TODO (2025-03-05): unskip once `atheris` can be installed on `ubuntu-24.04`,
8+
# see https://github.com/python/typeshed/pull/13582 and
9+
# https://github.com/google/atheris/issues/82
10+
skip = true

stubs/atheris/atheris/__init__.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from collections.abc import Callable
2+
3+
def Setup(
4+
args: list[str],
5+
test_one_input: Callable[[bytes], None],
6+
**kwargs: bool | Callable[[bytes, int, int], str | bytes] | Callable[[bytes, bytes, int, int], str | bytes] | None,
7+
) -> list[str]: ...
8+
def Fuzz() -> None: ...
9+
def Mutate(data: bytes, max_size: int) -> bytes: ...
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import Any
2+
3+
def hook_re_module() -> None: ...
4+
5+
class EnabledHooks:
6+
def __init__(self) -> None: ...
7+
def add(self, hook: str) -> None: ...
8+
def __contains__(self, hook: str) -> bool: ...
9+
10+
enabled_hooks: EnabledHooks
11+
12+
# args[1] is an arbitrary string method that is called
13+
# with the subsequent arguments, so they will vary
14+
def _hook_str(*args: Any, **kwargs: Any) -> bool: ...
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import types
2+
from collections.abc import Sequence
3+
from importlib import abc, machinery
4+
from typing_extensions import Self
5+
6+
def _should_skip(loader: abc.Loader) -> bool: ...
7+
8+
class AtherisMetaPathFinder(abc.MetaPathFinder):
9+
def __init__(
10+
self, include_packages: set[str], exclude_modules: set[str], enable_loader_override: bool, trace_dataflow: bool
11+
) -> None: ...
12+
def find_spec(
13+
self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = None
14+
) -> machinery.ModuleSpec | None: ...
15+
def invalidate_caches(self) -> None: ...
16+
17+
class AtherisSourceFileLoader:
18+
def __init__(self, name: str, path: str, trace_dataflow: bool) -> None: ...
19+
def get_code(self, fullname: str) -> types.CodeType | None: ...
20+
21+
class AtherisSourcelessFileLoader:
22+
def __init__(self, name: str, path: str, trace_dataflow: bool) -> None: ...
23+
def get_code(self, fullname: str) -> types.CodeType | None: ...
24+
25+
def make_dynamic_atheris_loader(loader: abc.Loader | type[abc.Loader], trace_dataflow: bool) -> abc.Loader: ...
26+
27+
class HookManager:
28+
def __init__(
29+
self, include_packages: set[str], exclude_modules: set[str], enable_loader_override: bool, trace_dataflow: bool
30+
) -> None: ...
31+
def __enter__(self) -> Self: ...
32+
def __exit__(self, *args: object) -> None: ...
33+
34+
def instrument_imports(
35+
include: Sequence[str] | None = None, exclude: Sequence[str] | None = None, enable_loader_override: bool = True
36+
) -> HookManager: ...
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from collections.abc import Callable
2+
from typing import TypeVar
3+
4+
_T = TypeVar("_T")
5+
6+
def instrument_func(func: Callable[..., _T]) -> Callable[..., _T]: ...
7+
def instrument_all() -> None: ...

stubs/atheris/atheris/utils.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import Protocol, type_check_only
2+
3+
def path() -> str: ...
4+
@type_check_only
5+
class _Writer(Protocol):
6+
def isatty(self) -> bool: ...
7+
def write(self, content: str, /) -> object: ...
8+
def flush(self) -> object: ...
9+
10+
class ProgressRenderer:
11+
def __init__(self, stream: _Writer, total_count: int) -> None: ...
12+
def render(self) -> None: ...
13+
def erase(self) -> None: ...
14+
def drop(self) -> None: ...
15+
@property
16+
def count(self) -> int: ...
17+
@count.setter
18+
def count(self, new_count: int) -> None: ...
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import types
2+
from typing import Final
3+
4+
PYTHON_VERSION: Final[tuple[int, int]]
5+
CONDITIONAL_JUMPS: Final[list[str]]
6+
UNCONDITIONAL_JUMPS: Final[list[str]]
7+
ENDS_FUNCTION: Final[list[str]]
8+
HAVE_REL_REFERENCE: Final[list[str]]
9+
HAVE_ABS_REFERENCE: Final[list[str]]
10+
REL_REFERENCE_IS_INVERTED: Final[list[str]]
11+
12+
def rel_reference_scale(opname: str) -> int: ...
13+
14+
REVERSE_CMP_OP: Final[list[int]]
15+
16+
def jump_arg_bytes(arg: int) -> int: ...
17+
def add_bytes_to_jump_arg(arg: int, size: int) -> int: ...
18+
19+
class ExceptionTableEntry:
20+
def __init__(self, start_offset: int, end_offset: int, target: int, depth: int, lasti: bool) -> None: ...
21+
def __eq__(self, other: object) -> bool: ...
22+
23+
class ExceptionTable:
24+
def __init__(self, entries: list[ExceptionTableEntry]) -> None: ...
25+
def __eq__(self, other: object) -> bool: ...
26+
27+
def generate_exceptiontable(original_code: types.CodeType, exception_table_entries: list[ExceptionTableEntry]) -> bytes: ...

0 commit comments

Comments
 (0)