diff --git a/.pytype/pyi/hgext/convert/hg.pyi b/.pytype/pyi/hgext/convert/hg.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvaGdleHQvY29udmVydC9oZy5weWk=..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvaGdleHQvY29udmVydC9oZy5weWk= 100644
--- a/.pytype/pyi/hgext/convert/hg.pyi
+++ b/.pytype/pyi/hgext/convert/hg.pyi
@@ -30,7 +30,7 @@
     tagsbranch: Any
     wlock: Any
     def __init__(self, ui, repotype, path) -> None: ...
-    def _calculatemergedfiles(self, source, p1ctx, p2ctx) -> Generator[nothing, Any, None]: ...
+    def _calculatemergedfiles(self, source, p1ctx, p2ctx) -> Generator[bytes, Any, None]: ...
     def _rewritesubstate(self, source, data) -> bytes: ...
     def _rewritetags(self, source, revmap, data) -> bytes: ...
     def after(self) -> None: ...
diff --git a/.pytype/pyi/hgext/git/manifest.pyi b/.pytype/pyi/hgext/git/manifest.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvaGdleHQvZ2l0L21hbmlmZXN0LnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvaGdleHQvZ2l0L21hbmlmZXN0LnB5aQ== 100644
--- a/.pytype/pyi/hgext/git/manifest.pyi
+++ b/.pytype/pyi/hgext/git/manifest.pyi
@@ -6,7 +6,7 @@
 from hgext.git import gitutil
 from mercurial import match as matchmod, pathutil, pycompat, util
 from mercurial.interfaces import repository
-from typing import Annotated, Any, Collection, Dict, Generator, Iterable, Iterator, List, Never, Optional, Tuple, Type, TypeVar, Union
+from typing import Annotated, Any, Collection, Dict, Iterable, Iterator, List, Never, Optional, Tuple, Type, TypeVar, Union
 
 pygit2: Any
 sha1nodeconstants: Type[mercurial.node.sha1nodeconstants]
@@ -30,7 +30,7 @@
     def __nonzero__(self) -> bool: ...
     def __setitem__(self, path: bytes, node: bytes) -> None: ...
     def _resolve_entry(self, path) -> Tuple[bytes, bytes]: ...
-    def _walkonetree(self, tree, match, subdir) -> Generator[bytes, Any, None]: ...
+    def _walkonetree(self, tree, match, subdir) -> Iterator[bytes]: ...
     def copy(self: _Tgittreemanifest) -> _Tgittreemanifest: ...
     def diff(self, other, match = ..., clean: bool = ...) -> Dict[bytes, Optional[Tuple[Tuple[Optional[bytes], bytes], Tuple[Optional[bytes], bytes]]]]: ...
     def dirs(self) -> Any: ...
diff --git a/.pytype/pyi/hgext/remotefilelog/remotefilectx.pyi b/.pytype/pyi/hgext/remotefilelog/remotefilectx.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvaGdleHQvcmVtb3RlZmlsZWxvZy9yZW1vdGVmaWxlY3R4LnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvaGdleHQvcmVtb3RlZmlsZWxvZy9yZW1vdGVmaWxlY3R4LnB5aQ== 100644
--- a/.pytype/pyi/hgext/remotefilelog/remotefilectx.pyi
+++ b/.pytype/pyi/hgext/remotefilelog/remotefilectx.pyi
@@ -3,5 +3,6 @@
 import collections
 import mercurial.dagop
 import time
+import typing
 from hgext.remotefilelog import shallowutil
 from mercurial import ancestor, context, error, phases, util
@@ -6,6 +7,6 @@
 from hgext.remotefilelog import shallowutil
 from mercurial import ancestor, context, error, phases, util
-from typing import Any, Generator, List, Optional, Tuple, Type, TypeVar, Union
+from typing import Any, Iterator, List, Optional, Tuple, Type, TypeVar, Union
 from typing_extensions import Buffer
 
 FASTLOG_TIMEOUT_IN_SECS: float
@@ -26,7 +27,7 @@
     def _verifylinknode(self, revs, linknode) -> bool: ...
     def ancestor(self, fc2, actx) -> Any: ...
     def ancestormap(self) -> Any: ...
-    def ancestors(self, followfirst = ...) -> Generator[nothing, Any, None]: ...
+    def ancestors(self, followfirst = ...) -> Iterator[remotefilectx]: ...
     def annotate(self, *args, **kwargs) -> List[mercurial.dagop.annotateline]: ...
     def children(self) -> List[nothing]: ...
     def copysource(self) -> Any: ...
diff --git a/.pytype/pyi/mercurial/__version__.pyi b/.pytype/pyi/mercurial/__version__.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL19fdmVyc2lvbl9fLnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL19fdmVyc2lvbl9fLnB5aQ== 100644
--- a/.pytype/pyi/mercurial/__version__.pyi
+++ b/.pytype/pyi/mercurial/__version__.pyi
@@ -1,3 +1,10 @@
 # (generated with --quick)
 
-version: bytes
+from typing import Any
+
+TYPE_CHECKING: bool
+VERSION_TUPLE: type
+__version__: str
+__version_tuple__: Any
+version: str
+version_tuple: Any
diff --git a/.pytype/pyi/mercurial/bundle2.pyi b/.pytype/pyi/mercurial/bundle2.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL2J1bmRsZTIucHlp..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL2J1bmRsZTIucHlp 100644
--- a/.pytype/pyi/mercurial/bundle2.pyi
+++ b/.pytype/pyi/mercurial/bundle2.pyi
@@ -12,7 +12,7 @@
 from mercurial import bookmarks, changegroup, encoding, error, obsolete, phases, pushkey, pycompat, requirements, scmutil, streamclone, tags, url, util
 from mercurial.interfaces import repository
 from mercurial.utils import stringutil, urlutil
-from typing import Annotated, Any, Callable, Dict, Generator, List, Never, Optional, Tuple, Type, TypeVar, Union, overload
+from typing import Annotated, Any, Callable, Dict, Generator, Iterator, List, Never, Optional, Tuple, Type, TypeVar, Union, overload
 from typing_extensions import Buffer
 
 Capabilities = Dict[bytes, Union[List[bytes], Tuple[bytes, ...]]]
@@ -64,7 +64,7 @@
     def _paramchunk(self) -> bytes: ...
     def addparam(self, name, value = ...) -> None: ...
     def addpart(self, part) -> None: ...
-    def getchunks(self) -> Generator[bytes, Any, None]: ...
+    def getchunks(self) -> Iterator[bytes]: ...
     def newpart(self, typeid, *args, **kwargs) -> bundlepart: ...
     def salvageoutput(self) -> list: ...
     def setcompression(self, alg, compopts = ...) -> None: ...
diff --git a/.pytype/pyi/mercurial/merge.pyi b/.pytype/pyi/mercurial/merge.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL21lcmdlLnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL21lcmdlLnB5aQ== 100644
--- a/.pytype/pyi/mercurial/merge.pyi
+++ b/.pytype/pyi/mercurial/merge.pyi
@@ -8,7 +8,7 @@
 from mercurial import copies, encoding, error, filemerge, match as matchmod, mergestate as mergestatemod, obsutil, pathutil, policy, pycompat, scmutil, subrepoutil, util, worker
 from mercurial.dirstateutils import timestamp
 from mercurial.utils import stringutil
-from typing import Annotated, Any, Dict, Generator, Optional, Set, Tuple, TypeVar, Union
+from typing import Annotated, Any, Dict, Generator, Iterable, Iterator, List, Optional, Set, Tuple, Type, TypeVar, Union
 from typing_extensions import Buffer
 
 FileData = Dict[bytes, Optional[Tuple[int, int, Optional[timestamp.timestamp]]]]
@@ -12,5 +12,7 @@
 from typing_extensions import Buffer
 
 FileData = Dict[bytes, Optional[Tuple[int, int, Optional[timestamp.timestamp]]]]
+FileMappingValue = Tuple[mergestatemod.MergeAction, Optional[tuple], bytes]
+MergeResultAction = Tuple[bytes, Optional[tuple], bytes]
 
 MAYBE_USE_RUST_UPDATE: bool
@@ -15,5 +17,6 @@
 
 MAYBE_USE_RUST_UPDATE: bool
+MergeResultData: Type[tuple]
 UPDATECHECK_ABORT: bytes
 UPDATECHECK_LINEAR: bytes
 UPDATECHECK_NONE: bytes
@@ -21,7 +24,6 @@
 nullrev: int
 rust_update_mod: Any
 
-_T1 = TypeVar('_T1')
 _T2 = TypeVar('_T2')
 
 class _unknowndirschecker:
@@ -33,6 +35,6 @@
 
 class mergeresult:
     __doc__: str
-    _actionmapping: collections.defaultdict
-    _commitinfo: collections.defaultdict
+    _actionmapping: Dict[mergestatemod.MergeAction, Dict[bytes, Tuple[tuple, bytes]]]
+    _commitinfo: collections.defaultdict[bytes, Any]
     _diverge: Any
@@ -38,3 +40,3 @@
     _diverge: Any
-    _filemapping: Any
+    _filemapping: Dict[bytes, Tuple[mergestatemod.MergeAction, Optional[tuple], bytes]]
     _renamedelete: Any
@@ -40,6 +42,6 @@
     _renamedelete: Any
-    actionsdict: Annotated[collections.defaultdict[nothing, Any], 'property']
-    commitinfo: Annotated[collections.defaultdict, 'property']
+    actionsdict: Annotated[Dict[mergestatemod.MergeAction, List[Tuple[bytes, Optional[tuple], bytes]]], 'property']
+    commitinfo: Annotated[collections.defaultdict[bytes, Any], 'property']
     diverge: Annotated[Dict[nothing, nothing], 'property']
     renamedelete: Annotated[Dict[nothing, nothing], 'property']
     def __init__(self) -> None: ...
@@ -43,10 +45,10 @@
     diverge: Annotated[Dict[nothing, nothing], 'property']
     renamedelete: Annotated[Dict[nothing, nothing], 'property']
     def __init__(self) -> None: ...
-    def addcommitinfo(self, filename, key, value) -> None: ...
-    def addfile(self, filename, action, data, message) -> None: ...
-    def filemap(self, sort = ...) -> Generator[nothing, Any, None]: ...
-    def files(self, actions = ...) -> Generator[nothing, Any, None]: ...
-    def getactions(self, actions, sort = ...) -> Generator[Tuple[Any, Any, Any], Any, None]: ...
-    def getfile(self, filename, default_return: _T1 = ...) -> Union[Tuple[Any, Any, Any], _T1]: ...
+    def addcommitinfo(self, filename: bytes, key, value) -> None: ...
+    def addfile(self, filename: bytes, action: mergestatemod.MergeAction, data: Optional[tuple], message) -> None: ...
+    def filemap(self, sort: bool = ...) -> Iterator[Tuple[bytes, tuple]]: ...
+    def files(self, actions: Optional[Iterable[mergestatemod.MergeAction]] = ...) -> Iterator[bytes]: ...
+    def getactions(self, actions: Iterable[mergestatemod.MergeAction], sort: bool = ...) -> Iterator[Tuple[bytes, Optional[tuple], bytes]]: ...
+    def getfile(self, filename: bytes, default_return: Optional[Tuple[mergestatemod.MergeAction, Optional[tuple], bytes]] = ...) -> Optional[Tuple[mergestatemod.MergeAction, Optional[tuple], bytes]]: ...
     def hasconflicts(self) -> bool: ...
@@ -52,7 +54,7 @@
     def hasconflicts(self) -> bool: ...
-    def len(self, actions = ...) -> int: ...
-    def mapaction(self, actionfrom, actionto, transform) -> None: ...
-    def removefile(self, filename) -> None: ...
+    def len(self, actions: Optional[Iterable[mergestatemod.MergeAction]] = ...) -> int: ...
+    def mapaction(self, actionfrom: mergestatemod.MergeAction, actionto: mergestatemod.MergeAction, transform) -> None: ...
+    def removefile(self, filename: bytes) -> None: ...
     def setactions(self, actions) -> None: ...
     def updatevalues(self, diverge, renamedelete) -> None: ...
 
@@ -67,5 +69,5 @@
 
 def _(message: bytes) -> bytes: ...
 def _advertisefsmonitor(repo, num_gets, p1node) -> None: ...
-def _checkcollision(repo, wmf, mresult) -> None: ...
+def _checkcollision(repo, wmf, mresult: Optional[mergeresult]) -> None: ...
 def _checkunknownfile(dirstate, wvfs, dircache, wctx, mctx, f, f2 = ...) -> Any: ...
@@ -71,8 +73,8 @@
 def _checkunknownfile(dirstate, wvfs, dircache, wctx, mctx, f, f2 = ...) -> Any: ...
-def _checkunknownfiles(repo, wctx, mctx, force, mresult, mergeforce) -> None: ...
-def _filesindirs(repo, manifest, dirs) -> Generator[Tuple[Any, bytes], Any, None]: ...
-def _filternarrowactions(narrowmatch, branchmerge, mresult) -> None: ...
-def _forgetremoved(wctx, mctx, branchmerge, mresult) -> None: ...
+def _checkunknownfiles(repo, wctx, mctx, force, mresult: mergeresult, mergeforce) -> None: ...
+def _filesindirs(repo, manifest, dirs) -> Iterator[Tuple[bytes, bytes]]: ...
+def _filternarrowactions(narrowmatch, branchmerge, mresult: mergeresult) -> None: ...
+def _forgetremoved(wctx, mctx, branchmerge, mresult: mergeresult) -> None: ...
 def _getcheckunknownconfig(repo, section, name) -> Any: ...
 def _getcwd() -> Optional[bytes]: ...
 def _pack(__fmt: Union[bytes, str], *v) -> bytes: ...
@@ -76,7 +78,7 @@
 def _getcheckunknownconfig(repo, section, name) -> Any: ...
 def _getcwd() -> Optional[bytes]: ...
 def _pack(__fmt: Union[bytes, str], *v) -> bytes: ...
-def _prefetchfiles(repo, ctx, mresult) -> None: ...
-def _resolvetrivial(repo, wctx, mctx, ancestor, mresult) -> None: ...
+def _prefetchfiles(repo, ctx, mresult: mergeresult) -> None: ...
+def _resolvetrivial(repo, wctx, mctx, ancestor, mresult: mergeresult) -> None: ...
 def _unpack(__format: Union[bytes, str], __buffer: Buffer) -> tuple: ...
 def _update(repo, node, branchmerge, force, ancestor = ..., mergeancestor = ..., labels = ..., matcher = ..., mergeforce = ..., updatedirstate = ..., updatecheck = ..., wc = ...) -> updateresult: ...
@@ -81,7 +83,7 @@
 def _unpack(__format: Union[bytes, str], __buffer: Buffer) -> tuple: ...
 def _update(repo, node, branchmerge, force, ancestor = ..., mergeancestor = ..., labels = ..., matcher = ..., mergeforce = ..., updatedirstate = ..., updatecheck = ..., wc = ...) -> updateresult: ...
-def applyupdates(repo, mresult, wctx, mctx, overwrite, wantfiledata, labels = ...) -> Tuple[updateresult, Any, Any]: ...
+def applyupdates(repo, mresult: mergeresult, wctx, mctx, overwrite, wantfiledata, labels = ...) -> Tuple[updateresult, Any, Any]: ...
 def back_out(ctx, parent = ..., wc = ...) -> Any: ...
 def batchget(repo, mctx, wctx, wantfiledata, actions) -> Generator[Tuple[bool, Union[Dict[Any, Tuple[Any, Any, timestamp.timestamp]], Tuple[int, Any]]], Any, None]: ...
 def batchremove(repo, wctx, actions) -> Generator[Tuple[int, Any], Any, None]: ...
 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, acceptremote, followcopies, matcher = ..., mergeforce = ...) -> mergeresult: ...
@@ -84,8 +86,8 @@
 def back_out(ctx, parent = ..., wc = ...) -> Any: ...
 def batchget(repo, mctx, wctx, wantfiledata, actions) -> Generator[Tuple[bool, Union[Dict[Any, Tuple[Any, Any, timestamp.timestamp]], Tuple[int, Any]]], Any, None]: ...
 def batchremove(repo, wctx, actions) -> Generator[Tuple[int, Any], Any, None]: ...
 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, acceptremote, followcopies, matcher = ..., mergeforce = ...) -> mergeresult: ...
-def checkpathconflicts(repo, wctx, mctx, mresult) -> None: ...
+def checkpathconflicts(repo, wctx, mctx, mresult: mergeresult) -> None: ...
 def clean_update(ctx, wc = ...) -> Any: ...
 def filter_ambiguous_files(repo, file_data: Dict[bytes, Optional[Tuple[int, int, Optional[timestamp.timestamp]]]]) -> Optional[Dict[bytes, Optional[Tuple[int, int, Optional[timestamp.timestamp]]]]]: ...
 def graft(repo, ctx, base = ..., labels = ..., keepparent = ..., keepconflictparent = ..., wctx = ...) -> Any: ...
diff --git a/.pytype/pyi/mercurial/patch.pyi b/.pytype/pyi/mercurial/patch.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3BhdGNoLnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3BhdGNoLnB5aQ== 100644
--- a/.pytype/pyi/mercurial/patch.pyi
+++ b/.pytype/pyi/mercurial/patch.pyi
@@ -9,6 +9,7 @@
 import os
 import re
 import shutil
+import typing
 import zlib
 from mercurial import copies, diffhelper, diffutil, encoding, error, mail, mdiff, pathutil, pycompat, scmutil, similar, util, vfs as vfsmod
 from mercurial.utils import dateutil, hashutil, procutil, stringutil
@@ -238,7 +239,7 @@
 def diffcontent(data1, data2, header: _T2, binary, opts) -> Tuple[Any, Any, _T2, Union[Iterable[Tuple[Optional[Tuple[int, int, int, int]], List[bytes]]], Tuple[Tuple[None, List[bytes]]]]]: ...
 def difffeatureopts(ui: mercurial.ui.ui, opts: Optional[Dict[bytes, Any]] = ..., untrusted: bool = ..., section: bytes = ..., git: bool = ..., whitespace: bool = ..., formatchanging: bool = ..., configprefix: bytes = ...) -> mdiff.diffopts: ...
 def diffhunks(repo, ctx1, ctx2, match = ..., changes = ..., opts = ..., losedatafn = ..., pathfn = ..., copy = ..., copysourcematch = ...) -> Any: ...
-def difflabel(func, *args, **kw) -> Generator[Tuple[Any, bytes], Any, None]: ...
+def difflabel(func, *args, **kw) -> Iterator[Tuple[Any, bytes]]: ...
 def diffopts(ui: mercurial.ui.ui, opts: Optional[Dict[bytes, Any]] = ..., untrusted: bool = ..., section: bytes = ..., configprefix: bytes = ...) -> mdiff.diffopts: ...
 def diffsinglehunk(hunklines) -> Generator[Tuple[Any, bytes], Any, None]: ...
 def diffsinglehunkinline(hunklines) -> Generator[Tuple[Any, bytes], Any, None]: ...
@@ -246,7 +247,7 @@
 def diffstatdata(lines) -> List[Tuple[Any, int, int, bool]]: ...
 def diffstatsum(stats) -> Tuple[int, Any, Any, Any, Any]: ...
 def diffstatui(*args, **kw) -> Generator[Tuple[bytes, bytes], Any, None]: ...
-def diffui(*args, **kw) -> Generator[Tuple[Any, bytes], Any, None]: ...
+def diffui(*args, **kw) -> Generator[Tuple[Any, bytes], Any, Any]: ...
 def extract(ui, fileobj) -> contextlib._GeneratorContextManager: ...
 def filterpatch(ui, headers, match, operation = ...) -> Tuple[list, Dict[nothing, nothing]]: ...
 def getmessages() -> Dict[bytes, Dict[bytes, bytes]]: ...
diff --git a/.pytype/pyi/mercurial/scmutil.pyi b/.pytype/pyi/mercurial/scmutil.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3NjbXV0aWwucHlp..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3NjbXV0aWwucHlp 100644
--- a/.pytype/pyi/mercurial/scmutil.pyi
+++ b/.pytype/pyi/mercurial/scmutil.pyi
@@ -19,7 +19,6 @@
 from typing_extensions import Buffer
 
 DEFAULT_RESOURCE: int
-RESOURCE_DEFAULT: int
 RESOURCE_HIGH: int
 RESOURCE_LOW: int
 RESOURCE_MAPPING: Dict[bytes, int]
diff --git a/.pytype/pyi/mercurial/store.pyi b/.pytype/pyi/mercurial/store.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3N0b3JlLnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3N0b3JlLnB5aQ== 100644
--- a/.pytype/pyi/mercurial/store.pyi
+++ b/.pytype/pyi/mercurial/store.pyi
@@ -10,7 +10,7 @@
 import typing
 from mercurial import changelog, error, filelog, manifest, policy, pycompat, revlog as revlogmod, util, vfs as vfsmod
 from mercurial.utils import hashutil
-from typing import Annotated, Any, Callable, Generator, List, Optional, Tuple, TypeVar, Union
+from typing import Annotated, Any, Callable, Generator, Iterator, List, Optional, Tuple, TypeVar, Union
 from typing_extensions import Buffer
 
 EXCLUDED: re.Pattern[bytes]
@@ -183,7 +183,7 @@
 def _hybridencode(path, dotencode) -> bytes: ...
 def _match_tracked_entry(entry: BaseStoreEntry, matcher) -> Any: ...
 def _plainhybridencode(f) -> Any: ...
-def _reserved() -> Generator[nothing, Any, None]: ...
+def _reserved() -> Iterator[int]: ...
 def _split_revlog_ext(filename) -> Tuple[Any, Any]: ...
 def decodedir(path) -> Any: ...
 def decodefilename(s) -> bytes: ...
diff --git a/.pytype/pyi/mercurial/streamclone.pyi b/.pytype/pyi/mercurial/streamclone.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3N0cmVhbWNsb25lLnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3N0cmVhbWNsb25lLnB5aQ== 100644
--- a/.pytype/pyi/mercurial/streamclone.pyi
+++ b/.pytype/pyi/mercurial/streamclone.pyi
@@ -7,7 +7,7 @@
 from mercurial import bookmarks, bundle2 as bundle2mod, cacheutil, error, narrowspec, phases, pycompat, requirements as requirementsmod, scmutil, store, transaction, util
 from mercurial.interfaces import repository
 from mercurial.revlogutils import nodemap
-from typing import Any, BinaryIO, Dict, Generator, List, Never, Optional, Tuple, TypeVar, Union
+from typing import Any, BinaryIO, Dict, Generator, Iterable, Iterator, List, Optional, Set, Tuple, TypeVar, Union
 
 _fileappend: int
 _filefull: int
@@ -34,10 +34,10 @@
     _copies: Optional[Dict[Any, bytes]]
     _counter: int
     _dst_dir: Optional[bytes]
-    _volatile_fps: Optional[Dict[Any, Tuple[Optional[int], BinaryIO]]]
-    def __call__(self, src) -> Never: ...
+    _volatile_fps: Optional[Dict[bytes, Tuple[Optional[int], BinaryIO]]]
+    def __call__(self, src: bytes) -> None: ...
     def __enter__(self: _TVolatileManager) -> _TVolatileManager: ...
     def __exit__(self, *args, **kwars) -> None: ...
     def __init__(self) -> None: ...
     def _flush_some_on_disk(self) -> None: ...
     def _init_tmp_copies(self) -> None: ...
@@ -39,7 +39,7 @@
     def __enter__(self: _TVolatileManager) -> _TVolatileManager: ...
     def __exit__(self, *args, **kwars) -> None: ...
     def __init__(self) -> None: ...
     def _flush_some_on_disk(self) -> None: ...
     def _init_tmp_copies(self) -> None: ...
-    def _keep_one(self, src) -> int: ...
+    def _keep_one(self, src: bytes) -> int: ...
     def open(self, src) -> contextlib._GeneratorContextManager: ...
@@ -45,5 +45,5 @@
     def open(self, src) -> contextlib._GeneratorContextManager: ...
-    def try_keep(self, src) -> Optional[int]: ...
+    def try_keep(self, src: bytes) -> Optional[int]: ...
 
 class streamcloneapplier:
     __doc__: str
@@ -54,10 +54,10 @@
 def _(message: bytes) -> bytes: ...
 def _copy_files(src_vfs_map, dst_vfs_map, entries, progress) -> bool: ...
 def _emit2(repo, entries) -> Generator[Any, Any, None]: ...
-def _emit3(repo, entries) -> Generator[Any, Any, None]: ...
-def _entries_walk(repo, includes, excludes, includeobsmarkers) -> Generator[Tuple[bytes, Any], Any, None]: ...
+def _emit3(repo, entries) -> Iterator[Optional[bytes]]: ...
+def _entries_walk(repo, includes, excludes, includeobsmarkers: bool) -> Generator[Tuple[bytes, Any], Any, None]: ...
 def _filterfull(entry: _T0, copy, vfsmap) -> Union[Tuple[Any, Any, Any, Any], _T0]: ...
 def _makemap(repo) -> Dict[bytes, Any]: ...
 def _test_sync_point_walk_1_2(repo) -> None: ...
 def _test_sync_point_walk_3(repo) -> None: ...
 def _test_sync_point_walk_4(repo) -> None: ...
@@ -59,7 +59,7 @@
 def _filterfull(entry: _T0, copy, vfsmap) -> Union[Tuple[Any, Any, Any, Any], _T0]: ...
 def _makemap(repo) -> Dict[bytes, Any]: ...
 def _test_sync_point_walk_1_2(repo) -> None: ...
 def _test_sync_point_walk_3(repo) -> None: ...
 def _test_sync_point_walk_4(repo) -> None: ...
-def _walkstreamfiles(repo, matcher = ..., phase = ..., obsolescence = ...) -> Any: ...
+def _walkstreamfiles(repo, matcher = ..., phase: bool = ..., obsolescence: bool = ...) -> Any: ...
 def _walkstreamfullstorefiles(repo) -> List[bytes]: ...
@@ -65,3 +65,3 @@
 def _walkstreamfullstorefiles(repo) -> List[bytes]: ...
-def allowservergeneration(repo) -> Any: ...
+def allowservergeneration(repo) -> bool: ...
 def applybundlev1(repo, fp) -> None: ...
@@ -67,7 +67,7 @@
 def applybundlev1(repo, fp) -> None: ...
-def applybundlev2(repo, fp, filecount, filesize, requirements) -> None: ...
-def applybundlev3(repo, fp, requirements) -> None: ...
-def canperformstreamclone(pullop, bundle2 = ...) -> Tuple[bool, Optional[set]]: ...
-def consumev1(repo, fp, filecount, bytecount) -> None: ...
-def consumev2(repo, fp, filecount, filesize) -> None: ...
+def applybundlev2(repo, fp, filecount: int, filesize: int, requirements: Iterable[bytes]) -> None: ...
+def applybundlev3(repo, fp, requirements: Iterable[bytes]) -> None: ...
+def canperformstreamclone(pullop, bundle2: bool = ...) -> Tuple[bool, Optional[set]]: ...
+def consumev1(repo, fp, filecount: int, bytecount: int) -> None: ...
+def consumev2(repo, fp, filecount: int, filesize: int) -> None: ...
 def consumev3(repo, fp) -> None: ...
@@ -73,9 +73,9 @@
 def consumev3(repo, fp) -> None: ...
-def generatebundlev1(repo, compression = ...) -> Tuple[Any, Generator[Any, Any, None]]: ...
-def generatev1(repo) -> Tuple[int, Any, Generator[Any, Any, None]]: ...
-def generatev1wireproto(repo) -> Generator[bytes, Any, None]: ...
-def generatev2(repo, includes, excludes, includeobsmarkers) -> Tuple[Any, Any, Generator[Any, Any, None]]: ...
-def generatev3(repo, includes, excludes, includeobsmarkers) -> Generator[Any, Any, None]: ...
+def generatebundlev1(repo, compression: bytes = ...) -> Tuple[Set[bytes], Iterator[bytes]]: ...
+def generatev1(repo) -> Tuple[int, int, Iterator[bytes]]: ...
+def generatev1wireproto(repo) -> Iterator[bytes]: ...
+def generatev2(repo, includes, excludes, includeobsmarkers: bool) -> Tuple[Any, Any, Generator[Any, Any, None]]: ...
+def generatev3(repo, includes, excludes, includeobsmarkers: bool) -> Iterator[Optional[bytes]]: ...
 def local_copy(src_repo, dest_repo) -> None: ...
 def maybeperformlegacystreamclone(pullop) -> None: ...
 def nested(*ctxs) -> contextlib._GeneratorContextManager: ...
@@ -79,6 +79,6 @@
 def local_copy(src_repo, dest_repo) -> None: ...
 def maybeperformlegacystreamclone(pullop) -> None: ...
 def nested(*ctxs) -> contextlib._GeneratorContextManager: ...
-def new_stream_clone_requirements(default_requirements, streamed_requirements) -> set: ...
-def readbundle1header(fp) -> Tuple[Any, Any, set]: ...
-def streamed_requirements(repo) -> Any: ...
+def new_stream_clone_requirements(default_requirements: Iterable[bytes], streamed_requirements: Iterable[bytes]) -> Set[bytes]: ...
+def readbundle1header(fp) -> Tuple[int, int, Set[bytes]]: ...
+def streamed_requirements(repo) -> Set[bytes]: ...
diff --git a/.pytype/pyi/mercurial/ui.pyi b/.pytype/pyi/mercurial/ui.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3VpLnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3VpLnB5aQ== 100644
--- a/.pytype/pyi/mercurial/ui.pyi
+++ b/.pytype/pyi/mercurial/ui.pyi
@@ -65,6 +65,7 @@
     _ocfg: Any
     _path_to_root: Any
     _progbar: Any
+    _readlineprompt: bool
     _reportuntrusted: Any
     _styles: Any
     _tcfg: Any
diff --git a/.pytype/pyi/mercurial/utils/cborutil.pyi b/.pytype/pyi/mercurial/utils/cborutil.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3V0aWxzL2Nib3J1dGlsLnB5aQ==..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3V0aWxzL2Nib3J1dGlsLnB5aQ== 100644
--- a/.pytype/pyi/mercurial/utils/cborutil.pyi
+++ b/.pytype/pyi/mercurial/utils/cborutil.pyi
@@ -1,7 +1,8 @@
 # (generated with --quick)
 
 import struct
-from typing import Annotated, Any, Callable, Dict, Generator, List, Optional, Tuple, Type, TypeVar, Union
+import typing
+from typing import Annotated, Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Type, TypeVar, Union
 
 BEGIN_INDEFINITE_ARRAY: bytes
 BEGIN_INDEFINITE_BYTESTRING: bytes
@@ -28,7 +29,7 @@
 SPECIAL_START_INDEFINITE_BYTESTRING: int
 SPECIAL_START_MAP: int
 SPECIAL_START_SET: int
-STREAM_ENCODERS: Dict[Type[Optional[Union[bytes, dict, int, list, set, tuple]]], Callable[[Any], Any]]
+STREAM_ENCODERS: Dict[Type[Optional[Union[bytes, dict, int, list, set, tuple]]], Callable[[Any], Iterator[bytes]]]
 STRUCT_BIG_UBYTE: struct.Struct
 STRUCT_BIG_ULONG: struct.Struct
 STRUCT_BIG_ULONGLONG: struct.Struct
@@ -52,5 +53,5 @@
     __doc__: str
     _chunks: list
     _decoder: sansiodecoder
-    _wanted: Any
+    _wanted: int
     def __init__(self) -> None: ...
@@ -56,6 +57,6 @@
     def __init__(self) -> None: ...
-    def decode(self, b) -> Tuple[bool, Any, Any]: ...
+    def decode(self, b) -> Tuple[bool, int, int]: ...
     def getavailable(self) -> list: ...
 
 class bytestringchunk(bytes):
     __doc__: str
@@ -58,10 +59,10 @@
     def getavailable(self) -> list: ...
 
 class bytestringchunk(bytes):
     __doc__: str
-    isfirst: Any
-    islast: Any
-    def __new__(cls: Type[_Tbytestringchunk], v, first = ..., last = ...) -> _Tbytestringchunk: ...
+    isfirst: bool
+    islast: bool
+    def __new__(cls: Type[_Tbytestringchunk], v, first: bool = ..., last: bool = ...) -> _Tbytestringchunk: ...
 
 class sansiodecoder:
     _STATE_NONE: int
@@ -79,6 +80,6 @@
     decodedbytecount: Any
     inprogress: Annotated[bool, 'property']
     def __init__(self) -> None: ...
-    def decode(self, b, offset = ...) -> Tuple[bool, Any, Any]: ...
+    def decode(self, b, offset: int = ...) -> Tuple[bool, int, int]: ...
     def getavailable(self) -> list: ...
 
@@ -83,5 +84,5 @@
     def getavailable(self) -> list: ...
 
-def _elementtointeger(b, i) -> Any: ...
+def _elementtointeger(b, i: int) -> int: ...
 def _mixedtypesortkey(v: _T0) -> Tuple[Any, _T0]: ...
 def decodeall(b) -> list: ...
@@ -86,17 +87,17 @@
 def _mixedtypesortkey(v: _T0) -> Tuple[Any, _T0]: ...
 def decodeall(b) -> list: ...
-def decodeitem(b, offset = ...) -> Tuple[bool, Any, Any, int]: ...
-def decodeuint(subtype: _T0, b, offset = ..., allowindefinite = ...) -> Tuple[bool, Any, Any]: ...
-def encodelength(majortype, length) -> bytes: ...
-def streamencode(v) -> Generator[Any, Any, None]: ...
-def streamencodearray(l) -> Generator[bytes, Any, None]: ...
-def streamencodearrayfromiter(it) -> Generator[bytes, Any, None]: ...
-def streamencodebool(b) -> Generator[bytes, Any, None]: ...
-def streamencodebytestring(v: _T0) -> Generator[Union[bytes, _T0], Any, None]: ...
-def streamencodebytestringfromiter(it) -> Generator[Any, Any, None]: ...
-def streamencodeindefinitebytestring(source, chunksize = ...) -> Generator[Any, Any, None]: ...
-def streamencodeint(v) -> Generator[bytes, Any, None]: ...
-def streamencodemap(d) -> Generator[bytes, Any, None]: ...
-def streamencodemapfromiter(it) -> Generator[bytes, Any, None]: ...
-def streamencodenone(v) -> Generator[bytes, Any, None]: ...
-def streamencodeset(s) -> Generator[Any, Any, None]: ...
+def decodeitem(b, offset: int = ...) -> Tuple[bool, Any, Any, int]: ...
+def decodeuint(subtype: int, b: bytes, offset: int = ..., allowindefinite: bool = ...) -> Tuple[bool, Any, int]: ...
+def encodelength(majortype: int, length: int) -> bytes: ...
+def streamencode(v) -> Iterator[bytes]: ...
+def streamencodearray(l) -> Iterator[bytes]: ...
+def streamencodearrayfromiter(it) -> Iterator[bytes]: ...
+def streamencodebool(b: bool) -> Iterator[bytes]: ...
+def streamencodebytestring(v: bytes) -> Iterator[bytes]: ...
+def streamencodebytestringfromiter(it: Iterable[bytes]) -> Iterator[bytes]: ...
+def streamencodeindefinitebytestring(source, chunksize: int = ...) -> Iterator[bytes]: ...
+def streamencodeint(v: int) -> Iterator[bytes]: ...
+def streamencodemap(d: dict) -> Iterator[bytes]: ...
+def streamencodemapfromiter(it: Iterable) -> Iterator[bytes]: ...
+def streamencodenone(v: None) -> Iterator[bytes]: ...
+def streamencodeset(s) -> Iterator[bytes]: ...
diff --git a/.pytype/pyi/mercurial/utils/stringutil.pyi b/.pytype/pyi/mercurial/utils/stringutil.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3V0aWxzL3N0cmluZ3V0aWwucHlp..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3V0aWxzL3N0cmluZ3V0aWwucHlp 100644
--- a/.pytype/pyi/mercurial/utils/stringutil.pyi
+++ b/.pytype/pyi/mercurial/utils/stringutil.pyi
@@ -8,7 +8,7 @@
 import types
 import typing
 from mercurial import encoding, error, pycompat
-from typing import Any, Callable, Dict, Generator, Optional, Tuple, Union, overload
+from typing import Any, Callable, Dict, Iterator, Optional, Tuple, Union, overload
 
 _MBTextWrapper: Any
 _booleans: Dict[bytes, bool]
@@ -43,7 +43,7 @@
 def parsemailmap(mailmapcontent) -> Dict[mailmapping, mailmapping]: ...
 def person(author: bytes) -> bytes: ...
 def pprint(o, bprefix: bool = ..., indent: int = ..., level: int = ...) -> bytes: ...
-def pprintgen(o, bprefix: bool = ..., indent: int = ..., level: int = ...) -> Generator[bytes, Any, None]: ...
+def pprintgen(o, bprefix: bool = ..., indent: int = ..., level: int = ...) -> Iterator[bytes]: ...
 def prettyrepr(o) -> bytes: ...
 @overload
 def reescape(pat: bytes) -> bytes: ...
diff --git a/.pytype/pyi/mercurial/wireprotoframing.pyi b/.pytype/pyi/mercurial/wireprotoframing.pyi
index dbbd2effbd9755ea7b9f7ca3263d2a47cac279e9_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3dpcmVwcm90b2ZyYW1pbmcucHlp..a2e47a86b33ba82dcf0da1643d1b8503cf210a0f_LnB5dHlwZS9weWkvbWVyY3VyaWFsL3dpcmVwcm90b2ZyYW1pbmcucHlp 100644
--- a/.pytype/pyi/mercurial/wireprotoframing.pyi
+++ b/.pytype/pyi/mercurial/wireprotoframing.pyi
@@ -1,5 +1,6 @@
 # (generated with --quick)
 
+import abc
 import attr
 import collections
 import io
@@ -8,7 +9,11 @@
 import zlib
 from mercurial import encoding, error, pycompat, util, wireprototypes
 from mercurial.utils import cborutil, stringutil
-from typing import Any, Dict, Generator, List, Optional, Tuple, Type, TypeVar, Union
+from typing import Any, Dict, Generator, Iterator, List, Optional, Protocol, Set, Tuple, Type, Union
+
+DecoderT = Type[Union[identitydecoder, zlibdecoder, zstd8mbdecoder]]
+EncoderT = Type[Union[identityencoder, zlibencoder, zstd8mbencoder]]
+HandleSendFramesReturnT = Tuple[bytes, Dict[bytes, Iterator[bytearray]]]
 
 ARGUMENT_RECORD_HEADER: struct.Struct
 DEFAULT_MAX_FRAME_SIZE: int
@@ -48,9 +53,21 @@
 STREAM_FLAG_ENCODING_APPLIED: int
 STREAM_FLAG_END_STREAM: int
 
-_T0 = TypeVar('_T0')
+class Decoder(Protocol):
+    __doc__: str
+    @abstractmethod
+    def decode(self, data) -> bytes: ...
+
+class Encoder(Protocol):
+    __doc__: str
+    @abstractmethod
+    def encode(self, data) -> bytes: ...
+    @abstractmethod
+    def finish(self) -> bytes: ...
+    @abstractmethod
+    def flush(self) -> bytes: ...
 
 class bufferingcommandresponseemitter:
     __doc__: str
     _chunks: list
     _chunkssize: int
@@ -52,8 +69,8 @@
 
 class bufferingcommandresponseemitter:
     __doc__: str
     _chunks: list
     _chunkssize: int
-    _maxsize: Any
-    _requestid: Any
+    _maxsize: int
+    _requestid: int
     _stream: Any
@@ -59,7 +76,7 @@
     _stream: Any
-    def __init__(self, stream, requestid, maxframesize = ...) -> None: ...
+    def __init__(self, stream, requestid: int, maxframesize: int = ...) -> None: ...
     def _flush(self) -> Generator[Any, Any, None]: ...
     def send(self, data) -> Generator[Any, Any, None]: ...
 
 class clientreactor:
     __doc__: str
@@ -61,10 +78,10 @@
     def _flush(self) -> Generator[Any, Any, None]: ...
     def send(self, data) -> Generator[Any, Any, None]: ...
 
 class clientreactor:
     __doc__: str
-    _activerequests: dict
-    _buffersends: Any
+    _activerequests: Dict[int, commandrequest]
+    _buffersends: bool
     _canissuecommands: bool
     _cansend: bool
     _clientcontentencoders: Any
@@ -68,9 +85,9 @@
     _canissuecommands: bool
     _cansend: bool
     _clientcontentencoders: Any
-    _hasmultiplesend: Any
-    _incomingstreams: Dict[Any, inputstream]
+    _hasmultiplesend: bool
+    _incomingstreams: Dict[int, inputstream]
     _nextrequestid: int
     _outgoingstream: outputstream
     _pendingrequests: collections.deque
     _protocolsettingssent: bool
@@ -73,6 +90,6 @@
     _nextrequestid: int
     _outgoingstream: outputstream
     _pendingrequests: collections.deque
     _protocolsettingssent: bool
-    _streamsettingsdecoders: Dict[Any, cborutil.bufferingdecoder]
+    _streamsettingsdecoders: Dict[int, cborutil.bufferingdecoder]
     _ui: Any
@@ -78,12 +95,12 @@
     _ui: Any
-    def __init__(self, ui, hasmultiplesend = ..., buffersends = ..., clientcontentencoders = ...) -> None: ...
-    def _makecommandframes(self, request) -> Generator[Any, Any, None]: ...
-    def _oncommandresponseframe(self, request, frame) -> Tuple[bytes, Dict[bytes, Any]]: ...
-    def _onerrorresponseframe(self, request, frame) -> Tuple[bytes, Dict[bytes, Any]]: ...
-    def _onstreamsettingsframe(self, frame) -> Tuple[bytes, Dict[bytes, bytes]]: ...
-    def callcommand(self, name, args, datafh = ..., redirect = ...) -> Tuple[commandrequest, bytes, Dict[bytes, Generator[Any, Any, None]]]: ...
-    def flushcommands(self) -> Tuple[bytes, Dict[bytes, Generator[nothing, Any, None]]]: ...
-    def onframerecv(self, frame) -> Tuple[bytes, Dict[bytes, Any]]: ...
+    def __init__(self, ui, hasmultiplesend: bool = ..., buffersends: bool = ..., clientcontentencoders = ...) -> None: ...
+    def _makecommandframes(self, request: commandrequest) -> Iterator[bytearray]: ...
+    def _oncommandresponseframe(self, request: commandrequest, frame: frame) -> Tuple[bytes, Dict[bytes, Union[bytes, int, commandrequest]]]: ...
+    def _onerrorresponseframe(self, request: commandrequest, frame: frame) -> Tuple[bytes, Dict[bytes, Any]]: ...
+    def _onstreamsettingsframe(self, frame: frame) -> Tuple[bytes, Dict[bytes, bytes]]: ...
+    def callcommand(self, name, args, datafh = ..., redirect = ...) -> Tuple[commandrequest, bytes, Dict[bytes, Generator[bytearray, Any, Any]]]: ...
+    def flushcommands(self) -> Tuple[bytes, Dict[bytes, Iterator[bytearray]]]: ...
+    def onframerecv(self, frame: frame) -> Tuple[bytes, Dict[bytes, Any]]: ...
 
 class commandrequest:
     __doc__: str
@@ -91,5 +108,5 @@
     datafh: Any
     name: Any
     redirect: Any
-    requestid: Any
+    requestid: int
     state: bytes
@@ -95,5 +112,5 @@
     state: bytes
-    def __init__(self, requestid, name, args, datafh = ..., redirect = ...) -> None: ...
+    def __init__(self, requestid: int, name, args, datafh = ..., redirect = ...) -> None: ...
 
 @attr.s
 class frame:
@@ -97,10 +114,10 @@
 
 @attr.s
 class frame:
-    requestid: Any
-    streamid: Any
-    streamflags: Any
-    typeid: Any
-    flags: Any
-    payload: Any
+    requestid: int
+    streamid: int
+    streamflags: int
+    typeid: int
+    flags: int
+    payload: bytes
     __doc__: str
@@ -106,6 +123,6 @@
     __doc__: str
-    def __init__(self, requestid, streamid, streamflags, typeid, flags, payload) -> None: ...
+    def __init__(self, requestid: int, streamid: int, streamflags: int, typeid: int, flags: int, payload: bytes) -> None: ...
     def __repr__(self) -> str: ...
 
 @attr.s
 class frameheader:
@@ -108,11 +125,11 @@
     def __repr__(self) -> str: ...
 
 @attr.s
 class frameheader:
-    length: Any
-    requestid: Any
-    streamid: Any
-    streamflags: Any
-    typeid: Any
-    flags: Any
+    length: int
+    requestid: int
+    streamid: int
+    streamflags: int
+    typeid: int
+    flags: int
     __doc__: str
@@ -118,3 +135,3 @@
     __doc__: str
-    def __init__(self, length, requestid, streamid, streamflags, typeid, flags) -> None: ...
+    def __init__(self, length: int, requestid: int, streamid: int, streamflags: int, typeid: int, flags: int) -> None: ...
 
@@ -120,4 +137,4 @@
 
-class identitydecoder:
+class identitydecoder(Decoder):
     __doc__: str
     def __init__(self, ui, extraobjs) -> None: ...
@@ -122,4 +139,4 @@
     __doc__: str
     def __init__(self, ui, extraobjs) -> None: ...
-    def decode(self, data: _T0) -> _T0: ...
+    def decode(self, data) -> bytes: ...
 
@@ -125,4 +142,4 @@
 
-class identityencoder:
+class identityencoder(Encoder):
     __doc__: str
     def __init__(self, ui) -> None: ...
@@ -127,8 +144,8 @@
     __doc__: str
     def __init__(self, ui) -> None: ...
-    def encode(self, data: _T0) -> _T0: ...
+    def encode(self, data) -> bytes: ...
     def finish(self) -> bytes: ...
     def flush(self) -> bytes: ...
 
 class inputstream(stream):
     __doc__: str
@@ -130,15 +147,15 @@
     def finish(self) -> bytes: ...
     def flush(self) -> bytes: ...
 
 class inputstream(stream):
     __doc__: str
-    _active: Any
-    _decoder: Optional[Union[identitydecoder, zlibdecoder, zstd8mbdecoder]]
-    streamid: Any
-    def __init__(self, streamid, active = ...) -> None: ...
-    def decode(self, data) -> Any: ...
-    def flush(self) -> Any: ...
-    def setdecoder(self, ui, name, extraobjs) -> None: ...
+    _active: bool
+    _decoder: Optional[Decoder]
+    streamid: int
+    def __init__(self, streamid: int, active: bool = ...) -> None: ...
+    def decode(self, data) -> bytes: ...
+    def flush(self) -> bytes: ...
+    def setdecoder(self, ui, name: bytes, extraobjs) -> None: ...
 
 class outputstream(stream):
     __doc__: str
@@ -142,8 +159,8 @@
 
 class outputstream(stream):
     __doc__: str
-    _active: Any
-    _encoder: Optional[Union[identityencoder, zlibencoder, zstd8mbencoder]]
-    _encodername: Any
-    streamid: Any
+    _active: bool
+    _encoder: Optional[Encoder]
+    _encodername: Optional[bytes]
+    streamid: int
     streamsettingssent: bool
@@ -149,4 +166,4 @@
     streamsettingssent: bool
-    def __init__(self, streamid, active = ...) -> None: ...
-    def encode(self, data) -> Any: ...
+    def __init__(self, streamid: int, active: bool = ...) -> None: ...
+    def encode(self, data) -> bytes: ...
     def finish(self) -> Optional[bytes]: ...
@@ -152,8 +169,8 @@
     def finish(self) -> Optional[bytes]: ...
-    def flush(self) -> Any: ...
-    def makeframe(self, requestid, typeid, flags, payload, encoded = ...) -> bytearray: ...
-    def makestreamsettingsframe(self, requestid) -> Any: ...
-    def setencoder(self, ui, name) -> None: ...
+    def flush(self) -> bytes: ...
+    def makeframe(self, requestid: int, typeid: int, flags: int, payload: bytes, encoded: bool = ...) -> bytearray: ...
+    def makestreamsettingsframe(self, requestid: int) -> Optional[bytearray]: ...
+    def setencoder(self, ui, name: bytes) -> None: ...
 
 class serverreactor:
     __doc__: str
@@ -157,10 +174,10 @@
 
 class serverreactor:
     __doc__: str
-    _activecommands: set
-    _bufferedframegens: list
-    _deferoutput: Any
-    _incomingstreams: Dict[Any, inputstream]
+    _activecommands: Set[int]
+    _bufferedframegens: List[Iterator[bytearray]]
+    _deferoutput: bool
+    _incomingstreams: Dict[int, inputstream]
     _nextoutgoingstreamid: int
     _outgoingstreams: Dict[int, outputstream]
     _protocolsettingsdecoder: Optional[cborutil.bufferingdecoder]
@@ -164,7 +181,7 @@
     _nextoutgoingstreamid: int
     _outgoingstreams: Dict[int, outputstream]
     _protocolsettingsdecoder: Optional[cborutil.bufferingdecoder]
-    _receivingcommands: Dict[Any, Dict[bytes, Optional[Union[bool, io.BytesIO]]]]
+    _receivingcommands: Dict[int, Dict[bytes, Optional[Union[bool, io.BytesIO]]]]
     _sendersettings: Dict[bytes, Any]
     _state: bytes
     _ui: Any
@@ -168,9 +185,9 @@
     _sendersettings: Dict[bytes, Any]
     _state: bytes
     _ui: Any
-    def __init__(self, ui, deferoutput = ...) -> None: ...
-    def _handlecommanddataframe(self, frame, entry) -> Any: ...
-    def _handlesendframes(self, framegen: _T0) -> Tuple[bytes, Dict[bytes, _T0]]: ...
-    def _makeerrorresult(self, msg: _T0) -> Tuple[bytes, Dict[bytes, _T0]]: ...
-    def _makeruncommandresult(self, requestid) -> Tuple[bytes, Dict[bytes, Any]]: ...
+    def __init__(self, ui, deferoutput: bool = ...) -> None: ...
+    def _handlecommanddataframe(self, frame: frame, entry) -> Tuple[bytes, Dict[bytes, Any]]: ...
+    def _handlesendframes(self, framegen: Iterator[bytearray]) -> Tuple[bytes, Dict[bytes, Iterator[bytearray]]]: ...
+    def _makeerrorresult(self, msg: bytes) -> Tuple[bytes, Dict[bytes, bytes]]: ...
+    def _makeruncommandresult(self, requestid: int) -> Tuple[bytes, Dict[bytes, Any]]: ...
     def _makewantframeresult(self) -> Tuple[bytes, Dict[bytes, bytes]]: ...
@@ -176,8 +193,8 @@
     def _makewantframeresult(self) -> Tuple[bytes, Dict[bytes, bytes]]: ...
-    def _onframecommandreceiving(self, frame) -> Any: ...
-    def _onframeerrored(self, frame) -> Tuple[bytes, Dict[bytes, bytes]]: ...
-    def _onframeidle(self, frame) -> Any: ...
-    def _onframeinitial(self, frame) -> Any: ...
-    def _onframeprotocolsettings(self, frame) -> Tuple[bytes, Dict[bytes, bytes]]: ...
-    def _validatecommandrequestframe(self, frame) -> Optional[Tuple[bytes, Dict[bytes, bytes]]]: ...
+    def _onframecommandreceiving(self, frame: frame) -> Any: ...
+    def _onframeerrored(self, frame: frame) -> Tuple[bytes, Dict[bytes, bytes]]: ...
+    def _onframeidle(self, frame: frame) -> Any: ...
+    def _onframeinitial(self, frame: frame) -> Any: ...
+    def _onframeprotocolsettings(self, frame: frame) -> Tuple[bytes, Dict[bytes, bytes]]: ...
+    def _validatecommandrequestframe(self, frame: frame) -> Optional[Tuple[bytes, Dict[bytes, bytes]]]: ...
     def makeoutputstream(self) -> outputstream: ...
@@ -183,9 +200,9 @@
     def makeoutputstream(self) -> outputstream: ...
-    def oncommanderror(self, stream, requestid, message, args = ...) -> Tuple[bytes, Dict[bytes, Generator[nothing, Any, None]]]: ...
-    def oncommandresponsereadyobjects(self, stream, requestid, objs) -> Tuple[bytes, Dict[bytes, Generator[Any, Any, None]]]: ...
-    def onframerecv(self, frame) -> Any: ...
-    def oninputeof(self) -> Tuple[bytes, Dict[bytes, Generator[nothing, Any, None]]]: ...
-    def onservererror(self, stream, requestid, msg) -> Tuple[bytes, Dict[bytes, Generator[nothing, Any, None]]]: ...
+    def oncommanderror(self, stream: stream, requestid: int, message: bytes, args = ...) -> Tuple[bytes, Dict[bytes, Iterator[bytearray]]]: ...
+    def oncommandresponsereadyobjects(self, stream, requestid: int, objs) -> Tuple[bytes, Dict[bytes, Iterator[bytearray]]]: ...
+    def onframerecv(self, frame: frame) -> Any: ...
+    def oninputeof(self) -> Tuple[bytes, Dict[bytes, Iterator[bytearray]]]: ...
+    def onservererror(self, stream: stream, requestid: int, msg: bytes) -> Tuple[bytes, Dict[bytes, Iterator[bytearray]]]: ...
 
 class stream:
     __doc__: str
@@ -189,8 +206,8 @@
 
 class stream:
     __doc__: str
-    _active: Any
-    streamid: Any
-    def __init__(self, streamid, active = ...) -> None: ...
-    def makeframe(self, requestid, typeid, flags, payload) -> bytearray: ...
+    _active: bool
+    streamid: int
+    def __init__(self, streamid: int, active: bool = ...) -> None: ...
+    def makeframe(self, requestid: int, typeid: int, flags: int, payload: bytes) -> bytearray: ...
 
@@ -196,6 +213,6 @@
 
-class zlibdecoder:
+class zlibdecoder(Decoder):
     _decompressor: zlib._Decompress
     def __init__(self, ui, extraobjs) -> None: ...
     def decode(self, data) -> bytes: ...
 
@@ -198,10 +215,10 @@
     _decompressor: zlib._Decompress
     def __init__(self, ui, extraobjs) -> None: ...
     def decode(self, data) -> bytes: ...
 
-class zlibencoder:
+class zlibencoder(Encoder):
     _compressor: Optional[zlib._Compress]
     _zlib: module
     def __init__(self, ui) -> None: ...
     def encode(self, data) -> bytes: ...
     def finish(self) -> bytes: ...
@@ -203,9 +220,9 @@
     _compressor: Optional[zlib._Compress]
     _zlib: module
     def __init__(self, ui) -> None: ...
     def encode(self, data) -> bytes: ...
     def finish(self) -> bytes: ...
-    def flush(self) -> Any: ...
+    def flush(self) -> bytes: ...
 
 class zstd8mbdecoder(zstdbasedecoder):
     _decompressor: Any
@@ -216,5 +233,5 @@
     _zstd: Any
     def __init__(self, ui) -> None: ...
 
-class zstdbasedecoder:
+class zstdbasedecoder(Decoder):
     _decompressor: Any
@@ -220,4 +237,4 @@
     _decompressor: Any
-    def __init__(self, maxwindowsize) -> None: ...
-    def decode(self, data) -> Any: ...
+    def __init__(self, maxwindowsize: int) -> None: ...
+    def decode(self, data) -> bytes: ...
 
@@ -223,4 +240,4 @@
 
-class zstdbaseencoder:
+class zstdbaseencoder(Encoder):
     _compressor: Any
     _zstd: Any
@@ -225,8 +242,8 @@
     _compressor: Any
     _zstd: Any
-    def __init__(self, level) -> None: ...
-    def encode(self, data) -> Any: ...
-    def finish(self) -> Any: ...
-    def flush(self) -> Any: ...
+    def __init__(self, level: int) -> None: ...
+    def encode(self, data) -> bytes: ...
+    def finish(self) -> bytes: ...
+    def flush(self) -> bytes: ...
 
 def _(message: bytes) -> bytes: ...
@@ -231,16 +248,16 @@
 
 def _(message: bytes) -> bytes: ...
-def createalternatelocationresponseframe(stream, requestid, location) -> Any: ...
-def createcommanderrorresponse(stream, requestid, message, args = ...) -> Generator[Any, Any, None]: ...
-def createcommandframes(stream, requestid, cmd, args, datafh = ..., maxframesize = ..., redirect = ...) -> Generator[Any, Any, None]: ...
-def createcommandresponseeosframes(stream, requestid, maxframesize = ...) -> Generator[Any, Any, None]: ...
-def createcommandresponseokframe(stream, requestid) -> Any: ...
-def createerrorframe(stream, requestid, msg, errtype) -> Generator[Any, Any, None]: ...
-def createtextoutputframe(stream, requestid, atoms, maxframesize = ...) -> Generator[Any, Any, None]: ...
-def ensureserverstream(stream) -> None: ...
-def humanflags(mapping, value) -> bytes: ...
-def makeframe(requestid, streamid, streamflags, typeid, flags, payload) -> bytearray: ...
-def makeframefromhumanstring(s) -> bytearray: ...
-def parseheader(data) -> frameheader: ...
+def createalternatelocationresponseframe(stream: outputstream, requestid: int, location) -> bytearray: ...
+def createcommanderrorresponse(stream: stream, requestid: int, message: bytes, args = ...) -> Iterator[bytearray]: ...
+def createcommandframes(stream: stream, requestid: int, cmd, args, datafh = ..., maxframesize: int = ..., redirect = ...) -> Iterator[bytearray]: ...
+def createcommandresponseeosframes(stream: outputstream, requestid: int, maxframesize: int = ...) -> Iterator[bytearray]: ...
+def createcommandresponseokframe(stream: outputstream, requestid: int) -> Optional[bytearray]: ...
+def createerrorframe(stream: stream, requestid: int, msg: bytes, errtype: bytes) -> Iterator[bytearray]: ...
+def createtextoutputframe(stream: stream, requestid: int, atoms, maxframesize: int = ...) -> Iterator[bytearray]: ...
+def ensureserverstream(stream: stream) -> None: ...
+def humanflags(mapping: Dict[bytes, int], value: int) -> bytes: ...
+def makeframe(requestid: int, streamid: int, streamflags: int, typeid: int, flags: int, payload: bytes) -> bytearray: ...
+def makeframefromhumanstring(s: bytes) -> bytearray: ...
+def parseheader(data: bytes) -> frameheader: ...
 def populatestreamencoders() -> None: ...
 def readframe(fh) -> Optional[frame]: ...