Mercurial > public > mercurial-scm > hg
comparison mercurial/unionrepo.py @ 51870: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 | f4733654f144 |
children | 8315175f678d |
comparison
equal
deleted
inserted
replaced
51869:0afd58c72175 | 51870:1b17309cdaab |
---|---|
12 """ | 12 """ |
13 | 13 |
14 from __future__ import annotations | 14 from __future__ import annotations |
15 | 15 |
16 import contextlib | 16 import contextlib |
17 | 17 import typing |
18 | 18 |
19 from .i18n import _ | 19 from .i18n import _ |
20 | 20 |
21 from . import ( | 21 from . import ( |
22 changelog, | 22 changelog, |
245 class unionpeer(localrepo.localpeer): | 245 class unionpeer(localrepo.localpeer): |
246 def canpush(self): | 246 def canpush(self): |
247 return False | 247 return False |
248 | 248 |
249 | 249 |
250 class unionrepository: | 250 _union_repo_baseclass = object |
251 | |
252 if typing.TYPE_CHECKING: | |
253 _union_repo_baseclass = localrepo.localrepository | |
254 | |
255 | |
256 class unionrepository(_union_repo_baseclass): | |
251 """Represents the union of data in 2 repositories. | 257 """Represents the union of data in 2 repositories. |
252 | 258 |
253 Instances are not usable if constructed directly. Use ``instance()`` | 259 Instances are not usable if constructed directly. Use ``instance()`` |
254 or ``makeunionrepository()`` to create a usable instance. | 260 or ``makeunionrepository()`` to create a usable instance. |
255 """ | 261 """ |
256 | 262 |
263 # noinspection PyMissingConstructor | |
257 def __init__(self, repo2, url): | 264 def __init__(self, repo2, url): |
258 self.repo2 = repo2 | 265 self.repo2 = repo2 |
259 self._url = url | 266 self._url = url |
260 | 267 |
261 self.ui.setconfig(b'phases', b'publish', False, b'unionrepo') | 268 self.ui.setconfig(b'phases', b'publish', False, b'unionrepo') |