typing: replace `localrepo` import in `phases` module with protocol class
This likely breaks a pytype cycle, but also pytype 2024.10.11 is getting smarter, and was able to sniff out some possible return types on `localrepo.__getitem__()` that would cause problems (if they were true): /home/mharbison/projects/mercurial/mercurial-devel/mercurial/phases.py:491:42: error: in _addwdir: No attribute 'phase' on list [attribute-error] In Optional[Union[list, mercurial.context.changectx, mercurial.context.workingctx]] if wdirrev in wdirsubset and repo[None].phase() in phases: ~~~~~~~~~~~~~~~~ /home/mharbison/projects/mercurial/mercurial-devel/mercurial/phases.py:491:42: error: in _addwdir: No attribute 'phase' on None [attribute-error] In Optional[Union[list, mercurial.context.changectx, mercurial.context.workingctx]] if wdirrev in wdirsubset and repo[None].phase() in phases: ~~~~~~~~~~~~~~~~ /home/mharbison/projects/mercurial/mercurial-devel/mercurial/phases.py:1098:24: error: in pushphase: No attribute 'phase' on list [attribute-error] In Union[bytes, list, mercurial.context.changectx, mercurial.context.workingctx] currentphase = repo[nhex].phase() ~~~~~~~~~~~~~~~~ /home/mharbison/projects/mercurial/mercurial-devel/mercurial/phases.py:1098:24: error: in pushphase: No attribute 'phase' on bytes [attribute-error] In Union[bytes, list, mercurial.context.changectx, mercurial.context.workingctx] currentphase = repo[nhex].phase() ~~~~~~~~~~~~~~~~ We probably need some `@overload` on the repo class and the protocol, but settle for using the (non-typed) interface for now. This trips over the usage of the private `_phasecache` attribute, but I'm not sure how to deal with this, so it's declared on the interface for now.
parent
d23188f6874c
Branches topic/default/vfs-actually-readonly
No related tags found
Pipeline #99605 skipped
Stage: build
Stage: checks
Stage: tests
Stage: platform-compat
Stage: py-version-compat
Loading
Please register or sign in to comment