Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 51816:71fb6e0a7a35
typing: add type hints to the `opener` attributes and arguments of revlog
When making revlog and filelog classes visible to pytype, it got confused quite
a bit in `mercurial/revlogutils/rewrite.py`, thinking it had a plain `Callable`,
and flagging additional methods on it like `join()` and `rename()`. I couldn't
figure out how it reduced to that (and PyCharm flagged `opener` references as
`Any`), but this makes it happy. So make this change before making the classes
visible.
The vfs class hierarchy is a bit wonky (e.g. `filteredvfs` is not a `vfs`), so
this may need to be revisited with a Protocol class that covers all of the `vfs`
classes. But for now, everything works.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 21 Aug 2024 16:13:14 -0400 |
parents | 278af66e6595 |
children | bcaa5d408657 |
comparison
equal
deleted
inserted
replaced
51815:438f4fca513e | 51816:71fb6e0a7a35 |
---|---|
89 policy, | 89 policy, |
90 pycompat, | 90 pycompat, |
91 revlogutils, | 91 revlogutils, |
92 templatefilters, | 92 templatefilters, |
93 util, | 93 util, |
94 vfs as vfsmod, | |
94 ) | 95 ) |
95 from .interfaces import ( | 96 from .interfaces import ( |
96 repository, | 97 repository, |
97 util as interfaceutil, | 98 util as interfaceutil, |
98 ) | 99 ) |
361 | 362 |
362 That layer exist to be able to delegate some operation to Rust, its | 363 That layer exist to be able to delegate some operation to Rust, its |
363 boundaries are arbitrary and based on what we can delegate to Rust. | 364 boundaries are arbitrary and based on what we can delegate to Rust. |
364 """ | 365 """ |
365 | 366 |
367 opener: vfsmod.vfs | |
368 | |
366 def __init__( | 369 def __init__( |
367 self, | 370 self, |
368 opener, | 371 opener: vfsmod.vfs, |
369 index, | 372 index, |
370 index_file, | 373 index_file, |
371 data_file, | 374 data_file, |
372 sidedata_file, | 375 sidedata_file, |
373 inline, | 376 inline, |
1291 index entry. | 1294 index entry. |
1292 """ | 1295 """ |
1293 | 1296 |
1294 _flagserrorclass = error.RevlogError | 1297 _flagserrorclass = error.RevlogError |
1295 | 1298 |
1299 opener: vfsmod.vfs | |
1300 | |
1296 @staticmethod | 1301 @staticmethod |
1297 def is_inline_index(header_bytes): | 1302 def is_inline_index(header_bytes): |
1298 """Determine if a revlog is inline from the initial bytes of the index""" | 1303 """Determine if a revlog is inline from the initial bytes of the index""" |
1299 if len(header_bytes) == 0: | 1304 if len(header_bytes) == 0: |
1300 return True | 1305 return True |
1309 | 1314 |
1310 _docket_file: Optional[bytes] | 1315 _docket_file: Optional[bytes] |
1311 | 1316 |
1312 def __init__( | 1317 def __init__( |
1313 self, | 1318 self, |
1314 opener, | 1319 opener: vfsmod.vfs, |
1315 target, | 1320 target, |
1316 radix, | 1321 radix, |
1317 postfix=None, # only exist for `tmpcensored` now | 1322 postfix=None, # only exist for `tmpcensored` now |
1318 checkambig=False, | 1323 checkambig=False, |
1319 mmaplargeindex=False, | 1324 mmaplargeindex=False, |