-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add types for xmldiff #14822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add types for xmldiff #14822
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version = "2.7.*" | ||
upstream_repository = "https://github.com/Shoobx/xmldiff" |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from _typeshed import Incomplete | ||
from typing import NamedTuple | ||
|
||
class DeleteNode(NamedTuple): | ||
node: str | ||
|
||
class InsertNode(NamedTuple): | ||
target: Incomplete | ||
tag: str | ||
position: int | ||
|
||
class RenameNode(NamedTuple): | ||
node: str | ||
tag: Incomplete | ||
|
||
class MoveNode(NamedTuple): | ||
node: str | ||
target: Incomplete | ||
position: int | ||
|
||
class UpdateTextIn(NamedTuple): | ||
node: str | ||
text: Incomplete | ||
|
||
class UpdateTextAfter(NamedTuple): | ||
node: str | ||
text: Incomplete | ||
|
||
class UpdateAttrib(NamedTuple): | ||
node: str | ||
name: str | ||
value: Incomplete | ||
|
||
class DeleteAttrib(NamedTuple): | ||
node: str | ||
name: str | ||
|
||
class InsertAttrib(NamedTuple): | ||
node: str | ||
name: str | ||
value: Incomplete | ||
|
||
class RenameAttrib(NamedTuple): | ||
node: str | ||
oldname: str | ||
newname: str | ||
|
||
class InsertComment(NamedTuple): | ||
target: Incomplete | ||
position: Incomplete | ||
text: Incomplete | ||
|
||
class InsertNamespace(NamedTuple): | ||
prefix: str | ||
uri: str | ||
|
||
class DeleteNamespace(NamedTuple): | ||
prefix: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Generator | ||
|
||
class Differ: | ||
F: float | ||
uniqueattrs: Incomplete | ||
fast_match: Incomplete | ||
best_match: Incomplete | ||
ignored_attrs: Incomplete | ||
def __init__( | ||
self, | ||
F: float | None = None, | ||
uniqueattrs=None, | ||
ratio_mode: str = "fast", | ||
fast_match: bool = False, | ||
best_match: bool = False, | ||
ignored_attrs=[], | ||
) -> None: ... | ||
left: Incomplete | ||
right: Incomplete | ||
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]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from _typeshed import Incomplete | ||
|
||
class diff_match_patch: | ||
Diff_Timeout: float | ||
Diff_EditCost: int | ||
Match_Threshold: float | ||
Match_Distance: int | ||
Patch_DeleteThreshold: float | ||
Patch_Margin: int | ||
Match_MaxBits: int | ||
def __init__(self) -> None: ... | ||
DIFF_DELETE: int | ||
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): ... | ||
|
||
class patch_obj: | ||
diffs: Incomplete | ||
start1: Incomplete | ||
start2: Incomplete | ||
length1: int | ||
length2: int | ||
def __init__(self) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Generator | ||
from typing import NamedTuple | ||
|
||
DIFF_NS: str | ||
DIFF_PREFIX: str | ||
INSERT_NAME: Incomplete | ||
DELETE_NAME: Incomplete | ||
REPLACE_NAME: Incomplete | ||
RENAME_NAME: Incomplete | ||
WS_BOTH: int | ||
WS_TEXT: int | ||
WS_TAGS: int | ||
WS_NONE: int | ||
T_OPEN: int | ||
T_CLOSE: int | ||
T_SINGLE: int | ||
PLACEHOLDER_START: int | ||
kasium marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
class BaseFormatter: | ||
def __init__(self, normalize=1, pretty_print: bool = False) -> None: ... | ||
def prepare(self, left_tree, right_tree) -> None: ... | ||
def format(self, diff, orig_tree) -> None: ... | ||
|
||
class PlaceholderEntry(NamedTuple): | ||
element: Incomplete | ||
ttype: Incomplete | ||
close_ph: Incomplete | ||
|
||
class PlaceholderMaker: | ||
text_tags: Incomplete | ||
formatting_tags: Incomplete | ||
placeholder2tag: Incomplete | ||
tag2placeholder: Incomplete | ||
placeholder: Incomplete | ||
diff_tags: Incomplete | ||
def __init__(self, text_tags=(), formatting_tags=()) -> None: ... | ||
def get_placeholder(self, element, ttype, close_ph): ... | ||
def is_placeholder(self, char): ... | ||
def is_formatting(self, element): ... | ||
def do_element(self, element) -> None: ... | ||
def do_tree(self, tree) -> None: ... | ||
def split_string(self, text): ... | ||
def undo_string(self, text): ... | ||
def undo_element(self, elem) -> None: ... | ||
def undo_tree(self, tree) -> None: ... | ||
def mark_diff(self, ph, action, attributes=None): ... | ||
def wrap_diff(self, text, action, attributes=None): ... | ||
|
||
class XMLFormatter(BaseFormatter): | ||
normalize: Incomplete | ||
pretty_print: Incomplete | ||
text_tags: Incomplete | ||
formatting_tags: Incomplete | ||
use_replace: Incomplete | ||
placeholderer: Incomplete | ||
def __init__( | ||
self, normalize=0, pretty_print: bool = True, text_tags=(), formatting_tags=(), use_replace: bool = False | ||
) -> None: ... | ||
def prepare(self, left_tree, right_tree) -> None: ... | ||
def finalize(self, result_tree) -> None: ... | ||
def format(self, diff, orig_tree, differ=None): ... | ||
def render(self, result): ... | ||
def handle_action(self, action, result) -> None: ... | ||
|
||
class DiffFormatter(BaseFormatter): | ||
normalize: Incomplete | ||
def __init__(self, normalize=1, pretty_print: bool = False) -> None: ... | ||
def prepare(self, left, right) -> None: ... | ||
def finalize(self, left, right) -> None: ... | ||
def format(self, diff, orig_tree): ... | ||
def handle_action(self, action): ... | ||
|
||
class XmlDiffFormatter(BaseFormatter): | ||
normalize: Incomplete | ||
def __init__(self, normalize=1, pretty_print: bool = False) -> None: ... | ||
def prepare(self, left, right) -> None: ... | ||
def finalize(self, left, right) -> None: ... | ||
def format(self, diff, orig_tree): ... | ||
def handle_action(self, action, orig_tree) -> Generator[Incomplete, Incomplete]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from argparse import ArgumentParser | ||
from collections.abc import Iterable, Mapping, Sequence | ||
from typing import Any, overload | ||
from typing_extensions import TypeAlias | ||
|
||
from xmldiff.actions import ( | ||
DeleteAttrib, | ||
DeleteNamespace, | ||
DeleteNode, | ||
InsertAttrib, | ||
InsertComment, | ||
InsertNamespace, | ||
InsertNode, | ||
MoveNode, | ||
RenameAttrib, | ||
RenameNode, | ||
UpdateAttrib, | ||
UpdateTextAfter, | ||
UpdateTextIn, | ||
) | ||
from xmldiff.formatting import BaseFormatter | ||
|
||
__version__: str | ||
FORMATTERS: Mapping[str, BaseFormatter] | ||
|
||
_ACTIONS: TypeAlias = ( | ||
DeleteNode | ||
| InsertNode | ||
| RenameNode | ||
| MoveNode | ||
| UpdateTextIn | ||
| UpdateTextAfter | ||
| UpdateAttrib | ||
| DeleteAttrib | ||
| InsertAttrib | ||
| RenameAttrib | ||
| InsertComment | ||
| InsertNamespace | ||
| DeleteNamespace | ||
) | ||
_ET: TypeAlias = Any # lxml.etree._ElementTree | ||
|
||
@overload | ||
def diff_trees(left: _ET, right: _ET, *, diff_options: dict[str, Any] | None = None, formatter: BaseFormatter = ...) -> str: ... | ||
@overload | ||
def diff_trees( | ||
left: _ET, right: _ET, diff_options: dict[str, Any] | None = None, formatter: None = None | ||
) -> Iterable[_ACTIONS]: ... | ||
@overload | ||
def diff_texts(left: str, right: str, *, diff_options: dict[str, Any] | None = None, formatter: BaseFormatter = ...) -> str: ... | ||
@overload | ||
def diff_texts( | ||
left: str, right: str, diff_options: dict[str, Any] | None = None, formatter: None = None | ||
) -> Iterable[_ACTIONS]: ... | ||
@overload | ||
def diff_files(left: str, right: str, *, diff_options: dict[str, Any] | None = None, formatter: BaseFormatter = ...) -> str: ... | ||
@overload | ||
def diff_files( | ||
left: str, right: str, diff_options: dict[str, Any] | None = None, formatter: None = None | ||
) -> Iterable[_ACTIONS]: ... | ||
def validate_F(arg: float | str) -> float: ... | ||
def make_diff_parser() -> ArgumentParser: ... | ||
def diff_command(args: Sequence[str] | None = None) -> int | None: ... | ||
def patch_tree(actions, tree): ... | ||
def patch_text(actions, tree): ... | ||
def patch_file(actions, tree, diff_encoding=None): ... | ||
def make_patch_parser(): ... | ||
def patch_command(args=None) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Generator | ||
|
||
class Patcher: | ||
@property | ||
def nsmap(self): ... | ||
def patch(self, actions, tree): ... | ||
def handle_action(self, action, tree) -> None: ... | ||
|
||
class DiffParser: | ||
def parse(self, diff) -> Generator[Incomplete]: ... | ||
def make_action(self, line): ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Generator | ||
from re import Pattern | ||
|
||
RESERVED_NS: Pattern[str] | ||
|
||
def post_order_traverse(node) -> Generator[Incomplete, Incomplete]: ... | ||
def reverse_post_order_traverse(node) -> Generator[Incomplete, Incomplete]: ... | ||
def breadth_first_traverse(node) -> Generator[Incomplete]: ... | ||
def longest_common_subsequence(left_sequence, right_sequence, eqfn=...): ... | ||
|
||
WHITESPACE: Incomplete | ||
|
||
def cleanup_whitespace(text): ... | ||
def getpath(element, tree=None): ... | ||
def make_ascii_tree(element): ... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.