changeset 51714:45d5e9a0f6a6

typing: add some type hints to fastannotate that have decayed in the last year Somewhere since 10db46e128d4, `_knownopts` decayed to `set` for unknown reasons. Also, `annotateopts.default` changed from bytes to str. While that is correct, I noticed that PyCharm was flagging the member fields as undefined in `shortstr()`, so add those to keep it happy. (There are no complaints from pytype because that module is excluded, due to the missing reference to `linelog.copyfrom()` that I'm not sure how to fix.)
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 18 Jul 2024 19:01:55 -0400
parents 74f1bf147a6d
children 7601978f9e9f
files hgext/fastannotate/commands.py hgext/fastannotate/context.py
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/fastannotate/commands.py	Tue Jul 23 12:12:22 2024 +0200
+++ b/hgext/fastannotate/commands.py	Thu Jul 18 19:01:55 2024 -0400
@@ -7,6 +7,9 @@
 
 
 import os
+from typing import (
+    Set,
+)
 
 from mercurial.i18n import _
 from mercurial import (
@@ -254,7 +257,7 @@
 
 
 _newopts = set()
-_knownopts = {
+_knownopts: Set[bytes] = {
     opt[1].replace(b'-', b'_')
     for opt in (fastannotatecommandargs['options'] + commands.globalopts)
 }
--- a/hgext/fastannotate/context.py	Tue Jul 23 12:12:22 2024 +0200
+++ b/hgext/fastannotate/context.py	Thu Jul 18 19:01:55 2024 -0400
@@ -174,12 +174,16 @@
         'followmerge': True,
     }
 
+    diffopts: mdiff.diffopts
+    followrename: bool
+    followmerge: bool
+
     def __init__(self, **opts):
         for k, v in self.defaults.items():
             setattr(self, k, opts.get(k, v))
 
     @util.propertycache
-    def shortstr(self):
+    def shortstr(self) -> bytes:
         """represent opts in a short string, suitable for a directory name"""
         result = b''
         if not self.followrename: