Mercurial > hg-stable
changeset 51911:1b17309cdaab
typing: make `unionrepository` subclass `localrepository` while type checking
This is the same change as 9d4ad05bc91c made for `bundlerepository`, for the
same reasons.
Also, add a comment here to suppress the PyCharm warning that the superclass
constructor is not called, that is new now that there's a simulated superclass.
That lack of a call is by design- `makeunionrepository()` does magic that
PyCharm isn't aware of. But PyCharm has been better at catching problems than
pytype in a lot of cases, so I'd like to reduce the bogus things it flags, to
make the real issues stand out.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 19 Sep 2024 16:19:29 -0400 |
parents | 0afd58c72175 |
children | 8315175f678d |
files | mercurial/unionrepo.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/unionrepo.py Wed Sep 18 21:00:20 2024 -0400 +++ b/mercurial/unionrepo.py Thu Sep 19 16:19:29 2024 -0400 @@ -14,7 +14,7 @@ from __future__ import annotations import contextlib - +import typing from .i18n import _ @@ -247,13 +247,20 @@ return False -class unionrepository: +_union_repo_baseclass = object + +if typing.TYPE_CHECKING: + _union_repo_baseclass = localrepo.localrepository + + +class unionrepository(_union_repo_baseclass): """Represents the union of data in 2 repositories. Instances are not usable if constructed directly. Use ``instance()`` or ``makeunionrepository()`` to create a usable instance. """ + # noinspection PyMissingConstructor def __init__(self, repo2, url): self.repo2 = repo2 self._url = url