##// END OF EJS Templates
typing: add a few type hints to `mercurial/revlog.py`...
Matt Harbison -
r52570:df6ce326 default
parent child Browse files
Show More
@@ -23,6 +23,11 import struct
23 import weakref
23 import weakref
24 import zlib
24 import zlib
25
25
26 from typing import (
27 Optional,
28 Tuple,
29 )
30
26 # import stuff from node for others to import from revlog
31 # import stuff from node for others to import from revlog
27 from .node import (
32 from .node import (
28 bin,
33 bin,
@@ -558,7 +563,7 class _InnerRevlog:
558 c = self._get_decompressor(t)
563 c = self._get_decompressor(t)
559 return c.decompress
564 return c.decompress
560
565
561 def _get_decompressor(self, t):
566 def _get_decompressor(self, t: bytes):
562 try:
567 try:
563 compressor = self._decompressors[t]
568 compressor = self._decompressors[t]
564 except KeyError:
569 except KeyError:
@@ -574,7 +579,7 class _InnerRevlog:
574 )
579 )
575 return compressor
580 return compressor
576
581
577 def compress(self, data):
582 def compress(self, data: bytes) -> Tuple[bytes, bytes]:
578 """Generate a possibly-compressed representation of data."""
583 """Generate a possibly-compressed representation of data."""
579 if not data:
584 if not data:
580 return b'', data
585 return b'', data
@@ -589,7 +594,7 class _InnerRevlog:
589 return b'', data
594 return b'', data
590 return b'u', data
595 return b'u', data
591
596
592 def decompress(self, data):
597 def decompress(self, data: bytes):
593 """Decompress a revlog chunk.
598 """Decompress a revlog chunk.
594
599
595 The chunk is expected to begin with a header identifying the
600 The chunk is expected to begin with a header identifying the
@@ -1296,6 +1301,8 class revlog:
1296 features = FEATURES_BY_VERSION[_format_version]
1301 features = FEATURES_BY_VERSION[_format_version]
1297 return features[b'inline'](_format_flags)
1302 return features[b'inline'](_format_flags)
1298
1303
1304 _docket_file: Optional[bytes]
1305
1299 def __init__(
1306 def __init__(
1300 self,
1307 self,
1301 opener,
1308 opener,
@@ -3081,7 +3088,7 class revlog:
3081 sidedata=sidedata,
3088 sidedata=sidedata,
3082 )
3089 )
3083
3090
3084 def compress(self, data):
3091 def compress(self, data: bytes) -> Tuple[bytes, bytes]:
3085 return self._inner.compress(data)
3092 return self._inner.compress(data)
3086
3093
3087 def decompress(self, data):
3094 def decompress(self, data):
General Comments 0
You need to be logged in to leave comments. Login now