Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"stubs/tqdm",
"stubs/vobject",
"stubs/workalendar",
"stubs/xmldiff",
],
"typeCheckingMode": "strict",
// TODO: Complete incomplete stubs
Expand Down
47 changes: 31 additions & 16 deletions stubs/xmldiff/xmldiff/actions.pyi
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
from _typeshed import Incomplete
from typing import NamedTuple
from typing import NamedTuple, TypeAlias

class DeleteNode(NamedTuple):
node: str

class InsertNode(NamedTuple):
target: Incomplete
target: str
tag: str
position: int

class RenameNode(NamedTuple):
node: str
tag: Incomplete
tag: str

class MoveNode(NamedTuple):
node: str
target: Incomplete
target: str
position: int

class UpdateTextIn(NamedTuple):
node: str
text: Incomplete
oldtext: Incomplete | None = None
text: str | None
oldtext: str | None = None

class UpdateTextAfter(NamedTuple):
node: str
text: Incomplete
oldtext: Incomplete | None = None
text: str | None
oldtext: str | None = None

class UpdateAttrib(NamedTuple):
node: str
name: str
value: Incomplete
value: str

class DeleteAttrib(NamedTuple):
node: str
Expand All @@ -40,21 +39,37 @@ class DeleteAttrib(NamedTuple):
class InsertAttrib(NamedTuple):
node: str
name: str
value: Incomplete
value: str

class RenameAttrib(NamedTuple):
node: str
oldname: str
newname: str

class InsertComment(NamedTuple):
target: Incomplete
position: Incomplete
text: Incomplete
target: str
position: int
text: str | None

class InsertNamespace(NamedTuple):
prefix: str
prefix: str | None
uri: str

class DeleteNamespace(NamedTuple):
prefix: str
prefix: str | None

_Action: TypeAlias = ( # noqa: Y047 # Used in other modules
DeleteNode
| InsertNode
| RenameNode
| MoveNode
| UpdateTextIn
| UpdateTextAfter
| UpdateAttrib
| DeleteAttrib
| InsertAttrib
| RenameAttrib
| InsertComment
| InsertNamespace
| DeleteNamespace
)
60 changes: 35 additions & 25 deletions stubs/xmldiff/xmldiff/diff.pyi
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import Literal
from collections.abc import Generator, Iterable, Sequence
from typing import Any, Literal, TypeAlias

from xmldiff import actions

_Element: TypeAlias = Any # lxml.etree._Element
_ElementTree: TypeAlias = Any # lxml.etree._ElementTree

class Differ:
F: float
uniqueattrs: Incomplete
fast_match: Incomplete
best_match: Incomplete
ignored_attrs: Incomplete
uniqueattrs: Iterable[str | Sequence[str]]
fast_match: bool
best_match: bool
ignored_attrs: Iterable[str]
def __init__(
self,
F: float | None = None,
uniqueattrs=None,
uniqueattrs: Iterable[str | Sequence[str]] | None = None,
ratio_mode: Literal["accurate", "fast", "faster"] = "fast",
fast_match: bool = False,
best_match: bool = False,
ignored_attrs=[],
ignored_attrs: Iterable[str] = [],
) -> None: ...
left: Incomplete
right: Incomplete
left: _Element | None
right: _Element | None
def clear(self) -> None: ...
def set_trees(self, left, right) -> None: ...
def append_match(self, lnode, rnode, max_match) -> None: ...
def match(self, left=None, right=None): ...
def node_ratio(self, left, right): ...
def node_text(self, node): ...
def node_attribs(self, node): ...
def leaf_ratio(self, left, right): ...
def child_ratio(self, left, right): ...
def update_node_tag(self, left, right) -> Generator[Incomplete]: ...
def update_node_attr(self, left, right) -> Generator[Incomplete]: ...
def update_node_text(self, left, right) -> Generator[Incomplete]: ...
def find_pos(self, node): ...
def align_children(self, left, right) -> Generator[Incomplete, None, Incomplete]: ...
def diff(self, left=None, right=None) -> Generator[Incomplete, Incomplete]: ...
def set_trees(self, left: _Element | _ElementTree, right: _Element | _ElementTree) -> None: ...
def append_match(self, lnode: _Element, rnode: _Element, max_match: float | None) -> None: ...
def match(
self, left: _Element | _ElementTree | None = None, right: _Element | _ElementTree | None = None
) -> list[tuple[_Element, _Element, float | None]]: ...
def node_ratio(self, left: _Element, right: _Element) -> float: ...
def node_text(self, node: _Element) -> str: ...
def node_attribs(self, node: _Element) -> dict[str, str]: ...
def leaf_ratio(self, left: _Element, right: _Element) -> float: ...
def child_ratio(self, left: _Element, right: _Element) -> float | None: ...
def update_node_tag(self, left: _Element, right: _Element) -> Generator[actions.RenameNode]: ...
def update_node_attr(
self, left: _Element, right: _Element
) -> Generator[actions.UpdateAttrib | actions.RenameAttrib | actions.InsertAttrib | actions.DeleteAttrib]: ...
def update_node_text(self, left: _Element, right: _Element) -> Generator[actions.UpdateTextIn | actions.UpdateTextAfter]: ...
def find_pos(self, node: _Element) -> int: ...
def align_children(self, left: _Element, right: _Element) -> Generator[actions.MoveNode]: ...
def diff(
self, left: _Element | _ElementTree | None = None, right: _Element | _ElementTree | None = None
) -> Generator[actions._Action]: ...
91 changes: 52 additions & 39 deletions stubs/xmldiff/xmldiff/diff_match_patch.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Sequence
from re import Pattern
from typing import TypeAlias, overload

_Diff: TypeAlias = tuple[int, str]

class diff_match_patch:
Diff_Timeout: float
Expand All @@ -13,46 +17,55 @@ class diff_match_patch:
DIFF_INSERT: int
DIFF_EQUAL: int
DIFF_REPLACE: int
def diff_main(self, text1, text2, checklines: bool = True, deadline=None): ...
def diff_compute(self, text1, text2, checklines, deadline): ...
def diff_lineMode(self, text1, text2, deadline): ...
def diff_bisect(self, text1, text2, deadline): ...
def diff_bisectSplit(self, text1, text2, x, y, deadline): ...
def diff_linesToChars(self, text1, text2): ...
def diff_charsToLines(self, diffs, lineArray) -> None: ...
def diff_commonPrefix(self, text1, text2): ...
def diff_commonSuffix(self, text1, text2): ...
def diff_commonOverlap(self, text1, text2): ...
def diff_halfMatch(self, text1, text2): ...
def diff_cleanupSemantic(self, diffs) -> None: ...
def diff_cleanupSemanticLossless(self, diffs): ...
BLANKLINEEND: Incomplete
BLANKLINESTART: Incomplete
def diff_cleanupEfficiency(self, diffs) -> None: ...
def diff_cleanupMerge(self, diffs) -> None: ...
def diff_xIndex(self, diffs, loc): ...
def diff_prettyHtml(self, diffs): ...
def diff_text1(self, diffs): ...
def diff_text2(self, diffs): ...
def diff_levenshtein(self, diffs): ...
def diff_toDelta(self, diffs): ...
def diff_fromDelta(self, text1, delta): ...
def match_main(self, text, pattern, loc): ...
def match_bitap(self, text, pattern, loc): ...
def match_alphabet(self, pattern): ...
def patch_addContext(self, patch, text) -> None: ...
def patch_make(self, a, b=None, c=None): ...
def patch_deepCopy(self, patches): ...
def patch_apply(self, patches, text): ...
def patch_addPadding(self, patches): ...
def patch_splitMax(self, patches) -> None: ...
def patch_toText(self, patches): ...
def patch_fromText(self, textline): ...
def diff_main(self, text1: str, text2: str, checklines: bool = True, deadline: float | None = None) -> list[_Diff]: ...
def diff_compute(self, text1: str, text2: str, checklines: bool, deadline: float) -> list[_Diff]: ...
def diff_lineMode(self, text1: str, text2: str, deadline: float) -> list[_Diff]: ...
def diff_bisect(self, text1: str, text2: str, deadline: float) -> list[_Diff]: ...
def diff_bisectSplit(self, text1: str, text2: str, x: int, y: int, deadline: float) -> list[_Diff]: ...
def diff_linesToChars(self, text1: str, text2: str) -> tuple[str, str, list[str]]: ...
def diff_charsToLines(self, diffs: list[_Diff], lineArray: Sequence[str]) -> None: ...
def diff_commonPrefix(self, text1: str, text2: str) -> int: ...
def diff_commonSuffix(self, text1: str, text2: str) -> int: ...
def diff_commonOverlap(self, text1: str, text2: str) -> int: ...
def diff_halfMatch(self, text1: str, text2: str) -> tuple[str, str, str, str, str] | None: ...
def diff_cleanupSemantic(self, diffs: list[_Diff]) -> None: ...
def diff_cleanupSemanticLossless(self, diffs: list[_Diff]) -> None: ...
BLANKLINEEND: Pattern[str]
BLANKLINESTART: Pattern[str]
def diff_cleanupEfficiency(self, diffs: list[_Diff]) -> None: ...
def diff_cleanupMerge(self, diffs: list[_Diff]) -> None: ...
def diff_xIndex(self, diffs: Sequence[_Diff], loc: int) -> int: ...
def diff_prettyHtml(self, diffs: Sequence[_Diff]) -> str: ...
def diff_text1(self, diffs: Sequence[_Diff]) -> str: ...
def diff_text2(self, diffs: Sequence[_Diff]) -> str: ...
def diff_levenshtein(self, diffs: Sequence[_Diff]) -> int: ...
def diff_toDelta(self, diffs: Sequence[_Diff]) -> str: ...
def diff_fromDelta(self, text1: str, delta: str) -> list[_Diff]: ...
def match_main(self, text: str, pattern: str, loc: int) -> int: ...
def match_bitap(self, text: str, pattern: str, loc: int) -> int: ...
def match_alphabet(self, pattern: str) -> dict[str, int]: ...
def patch_addContext(self, patch: patch_obj, text: str) -> None: ...

@overload
def patch_make(self, a: str, b: str, c: None = None) -> list[patch_obj]: ...
@overload
def patch_make(self, a: list[_Diff], b: None = None, c: None = None) -> list[patch_obj]: ...
@overload
def patch_make(self, a: str, b: list[_Diff], c: None = None) -> list[patch_obj]: ...
@overload
def patch_make(self, a: str, b: str, c: list[_Diff]) -> list[patch_obj]: ...

def patch_deepCopy(self, patches: Iterable[patch_obj]) -> list[patch_obj]: ...
def patch_apply(self, patches: Iterable[patch_obj], text: str) -> tuple[str, list[bool]]: ...
def patch_addPadding(self, patches: Sequence[patch_obj]) -> str: ...
def patch_splitMax(self, patches: list[patch_obj]) -> None: ...
def patch_toText(self, patches: Iterable[patch_obj]) -> str: ...
def patch_fromText(self, textline: str) -> list[patch_obj]: ...

class patch_obj:
diffs: Incomplete
start1: Incomplete
start2: Incomplete
diffs: list[_Diff]
start1: int | None
start2: int | None
length1: int
length2: int
def __init__(self) -> None: ...
Loading
Loading