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.
--- 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