mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Add stubs for whatthepatch (#7492)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
1
stubs/whatthepatch/METADATA.toml
Normal file
1
stubs/whatthepatch/METADATA.toml
Normal file
@@ -0,0 +1 @@
|
||||
version = "1.0.*"
|
||||
2
stubs/whatthepatch/whatthepatch/__init__.pyi
Normal file
2
stubs/whatthepatch/whatthepatch/__init__.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
from .apply import apply_diff as apply_diff
|
||||
from .patch import parse_patch as parse_patch
|
||||
8
stubs/whatthepatch/whatthepatch/apply.pyi
Normal file
8
stubs/whatthepatch/whatthepatch/apply.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from collections.abc import Iterable
|
||||
|
||||
from . import patch as patch
|
||||
from .exceptions import HunkApplyException as HunkApplyException, SubprocessException as SubprocessException
|
||||
from .snippets import remove as remove, which as which
|
||||
|
||||
def apply_patch(diffs: patch.diffobj | Iterable[patch.diffobj]) -> None: ...
|
||||
def apply_diff(diff: patch.diffobj, text: str | Iterable[str], reverse: bool = ..., use_patch: bool = ...) -> list[str]: ...
|
||||
14
stubs/whatthepatch/whatthepatch/exceptions.pyi
Normal file
14
stubs/whatthepatch/whatthepatch/exceptions.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
class WhatThePatchException(Exception): ...
|
||||
|
||||
class HunkException(WhatThePatchException):
|
||||
hunk: int | None
|
||||
def __init__(self, msg: str, hunk: int | None = ...) -> None: ...
|
||||
|
||||
class ApplyException(WhatThePatchException): ...
|
||||
|
||||
class SubprocessException(ApplyException):
|
||||
code: int
|
||||
def __init__(self, msg: str, code: int) -> None: ...
|
||||
|
||||
class HunkApplyException(HunkException, ApplyException, ValueError): ...
|
||||
class ParseException(HunkException, ValueError): ...
|
||||
77
stubs/whatthepatch/whatthepatch/patch.pyi
Normal file
77
stubs/whatthepatch/whatthepatch/patch.pyi
Normal file
@@ -0,0 +1,77 @@
|
||||
from collections.abc import Iterable, Iterator
|
||||
from typing import NamedTuple, Pattern
|
||||
|
||||
from . import exceptions as exceptions
|
||||
from .snippets import findall_regex as findall_regex, split_by_regex as split_by_regex
|
||||
|
||||
class header(NamedTuple):
|
||||
index_path: str | None
|
||||
old_path: str
|
||||
old_version: str | None
|
||||
new_path: str
|
||||
new_version: str | None
|
||||
|
||||
class diffobj(NamedTuple):
|
||||
header: header | None
|
||||
changes: list[Change] | None
|
||||
text: str
|
||||
|
||||
class Change(NamedTuple):
|
||||
old: int | None
|
||||
new: int | None
|
||||
line: int | None
|
||||
hunk: int
|
||||
|
||||
file_timestamp_str: str
|
||||
diffcmd_header: Pattern[str]
|
||||
unified_header_index: Pattern[str]
|
||||
unified_header_old_line: Pattern[str]
|
||||
unified_header_new_line: Pattern[str]
|
||||
unified_hunk_start: Pattern[str]
|
||||
unified_change: Pattern[str]
|
||||
context_header_old_line: Pattern[str]
|
||||
context_header_new_line: Pattern[str]
|
||||
context_hunk_start: Pattern[str]
|
||||
context_hunk_old: Pattern[str]
|
||||
context_hunk_new: Pattern[str]
|
||||
context_change: Pattern[str]
|
||||
ed_hunk_start: Pattern[str]
|
||||
ed_hunk_end: Pattern[str]
|
||||
rcs_ed_hunk_start: Pattern[str]
|
||||
default_hunk_start: Pattern[str]
|
||||
default_hunk_mid: Pattern[str]
|
||||
default_change: Pattern[str]
|
||||
git_diffcmd_header: Pattern[str]
|
||||
git_header_index: Pattern[str]
|
||||
git_header_old_line: Pattern[str]
|
||||
git_header_new_line: Pattern[str]
|
||||
git_header_file_mode: Pattern[str]
|
||||
git_header_binary_file: Pattern[str]
|
||||
bzr_header_index: Pattern[str]
|
||||
bzr_header_old_line: Pattern[str]
|
||||
bzr_header_new_line: Pattern[str]
|
||||
svn_header_index: Pattern[str]
|
||||
svn_header_timestamp_version: Pattern[str]
|
||||
svn_header_timestamp: Pattern[str]
|
||||
cvs_header_index: Pattern[str]
|
||||
cvs_header_rcs: Pattern[str]
|
||||
cvs_header_timestamp: Pattern[str]
|
||||
cvs_header_timestamp_colon: Pattern[str]
|
||||
old_cvs_diffcmd_header: Pattern[str]
|
||||
|
||||
def parse_patch(text: str | Iterable[str]) -> Iterator[diffobj]: ...
|
||||
def parse_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_scm_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_diff_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_diff(text: str | Iterable[str]) -> list[Change] | None: ...
|
||||
def parse_git_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_svn_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_cvs_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_diffcmd_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_unified_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_context_header(text: str | Iterable[str]) -> header | None: ...
|
||||
def parse_default_diff(text: str | Iterable[str]) -> list[Change] | None: ...
|
||||
def parse_unified_diff(text: str | Iterable[str]) -> list[Change] | None: ...
|
||||
def parse_context_diff(text: str | Iterable[str]) -> list[Change] | None: ...
|
||||
def parse_ed_diff(text: str | Iterable[str]) -> list[Change] | None: ...
|
||||
def parse_rcs_ed_diff(text: str | Iterable[str]) -> list[Change] | None: ...
|
||||
7
stubs/whatthepatch/whatthepatch/snippets.pyi
Normal file
7
stubs/whatthepatch/whatthepatch/snippets.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
from collections.abc import Sequence
|
||||
from typing import Pattern
|
||||
|
||||
def remove(path: str) -> None: ...
|
||||
def findall_regex(items: Sequence[str], regex: Pattern[str]) -> list[int]: ...
|
||||
def split_by_regex(items: Sequence[str], regex: Pattern[str]) -> list[Sequence[str]]: ...
|
||||
def which(program: str) -> str | None: ...
|
||||
Reference in New Issue
Block a user