comparison hgext/fastannotate/commands.py @ 51710: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 d718eddf01d9
children f4733654f144
comparison
equal deleted inserted replaced
51709:74f1bf147a6d 51710:45d5e9a0f6a6
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 8
9 import os 9 import os
10 from typing import (
11 Set,
12 )
10 13
11 from mercurial.i18n import _ 14 from mercurial.i18n import _
12 from mercurial import ( 15 from mercurial import (
13 commands, 16 commands,
14 encoding, 17 encoding,
252 formatter.write(result, lines, existinglines=existinglines) 255 formatter.write(result, lines, existinglines=existinglines)
253 formatter.end() 256 formatter.end()
254 257
255 258
256 _newopts = set() 259 _newopts = set()
257 _knownopts = { 260 _knownopts: Set[bytes] = {
258 opt[1].replace(b'-', b'_') 261 opt[1].replace(b'-', b'_')
259 for opt in (fastannotatecommandargs['options'] + commands.globalopts) 262 for opt in (fastannotatecommandargs['options'] + commands.globalopts)
260 } 263 }
261 264
262 265