typing: declare the `_phasesets` member of `phasecache` to be `Optional`
authorMatt Harbison <matt_harbison@yahoo.com>
Sat, 17 Aug 2024 17:38:35 -0400
changeset 51810 07086b3ad502
parent 51809 45270e286bdc
child 51811 673b07a1db08
typing: declare the `_phasesets` member of `phasecache` to be `Optional` Something in this area got flagged while making the repository class visible to pytype (instead of being typed as `Any`). A None assignment to something not optional is wrong, and when I tried setting it to `{}` to keep it non-Optional, some tests failed. There are checks for the attr being None elsewhere, so this seems to have just been an oversight.
mercurial/phases.py
--- a/mercurial/phases.py	Fri Aug 16 18:11:52 2024 -0400
+++ b/mercurial/phases.py	Sat Aug 17 17:38:35 2024 -0400
@@ -387,7 +387,7 @@
             self._phaseroots: Phaseroots = loaded[0]
             self.dirty: bool = loaded[1]
             self._loadedrevslen = 0
-            self._phasesets: PhaseSets = None
+            self._phasesets: Optional[PhaseSets] = None
 
     def hasnonpublicphases(self, repo: "localrepo.localrepository") -> bool:
         """detect if there are revisions with non-public phase"""