# HG changeset patch # User Matt Harbison # Date 2024-07-18 23:01:55 # Node ID 45d5e9a0f6a6290fd5a364bc170afa24e3d28c33 # Parent 74f1bf147a6d1cd0b936b886478fe088d503b7ad 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.) diff --git a/hgext/fastannotate/commands.py b/hgext/fastannotate/commands.py --- a/hgext/fastannotate/commands.py +++ b/hgext/fastannotate/commands.py @@ -7,6 +7,9 @@ import os +from typing import ( + Set, +) from mercurial.i18n import _ from mercurial import ( @@ -254,7 +257,7 @@ def fastannotate(ui, repo, *pats, **opts _newopts = set() -_knownopts = { +_knownopts: Set[bytes] = { opt[1].replace(b'-', b'_') for opt in (fastannotatecommandargs['options'] + commands.globalopts) } diff --git a/hgext/fastannotate/context.py b/hgext/fastannotate/context.py --- a/hgext/fastannotate/context.py +++ b/hgext/fastannotate/context.py @@ -174,12 +174,16 @@ class annotateopts: '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: