Mercurial > forks > mercurial
changeset 53244:1b1d7cc9d30e
revlog: convert version features dict to a `TypedDict`
Every key for each version corresponds to the same value type, so typing them
out explicitly means we don't have to handle the union of all value types for
every key.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 30 Apr 2025 00:12:23 -0400 |
parents | d9c7a3e4b95a |
children | af86422250b2 |
files | mercurial/revlogutils/constants.py |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlogutils/constants.py Wed Apr 30 11:23:27 2025 -0400 +++ b/mercurial/revlogutils/constants.py Wed Apr 30 00:12:23 2025 -0400 @@ -10,6 +10,12 @@ from __future__ import annotations import struct +import typing + +from typing import ( + Callable, + TypedDict, +) from ..interfaces import repository from .. import revlogutils @@ -278,7 +284,17 @@ return lambda flags: bool(flags & flag) -FEATURES_BY_VERSION = { +if typing.TYPE_CHECKING: + _FromFlagsFnc = Callable[[int], bool] + + class RevlogFeatures(TypedDict): + inline: _FromFlagsFnc + generaldelta: _FromFlagsFnc + sidedata: bool + docket: bool + + +FEATURES_BY_VERSION: dict[int, RevlogFeatures] = { REVLOGV0: { 'inline': _no, 'generaldelta': _no,