##// END OF EJS Templates
typing: add typehints to mercurial/diffutil.py...
Matt Harbison -
r51142:b8cac4e3 stable
parent child Browse files
Show More
@@ -7,6 +7,13 b''
7 7 # This software may be used and distributed according to the terms of the
8 8 # GNU General Public License version 2 or any later version.
9 9
10 import typing
11
12 from typing import (
13 Any,
14 Dict,
15 Optional,
16 )
10 17
11 18 from .i18n import _
12 19
@@ -15,10 +22,20 b' from . import ('
15 22 pycompat,
16 23 )
17 24
25 if typing.TYPE_CHECKING:
26 from . import ui as uimod
27
28 # TODO: narrow the value after the config module is typed
29 _Opts = Dict[bytes, Any]
30
18 31
19 32 def diffallopts(
20 ui, opts=None, untrusted=False, section=b'diff', configprefix=b''
21 ):
33 ui: "uimod.ui",
34 opts: Optional[_Opts] = None,
35 untrusted: bool = False,
36 section: bytes = b'diff',
37 configprefix: bytes = b'',
38 ) -> mdiff.diffopts:
22 39 '''return diffopts with all features supported and parsed'''
23 40 return difffeatureopts(
24 41 ui,
@@ -33,15 +50,15 b' def diffallopts('
33 50
34 51
35 52 def difffeatureopts(
36 ui,
37 opts=None,
38 untrusted=False,
39 section=b'diff',
40 git=False,
41 whitespace=False,
42 formatchanging=False,
43 configprefix=b'',
44 ):
53 ui: "uimod.ui",
54 opts: Optional[_Opts] = None,
55 untrusted: bool = False,
56 section: bytes = b'diff',
57 git: bool = False,
58 whitespace: bool = False,
59 formatchanging: bool = False,
60 configprefix: bytes = b'',
61 ) -> mdiff.diffopts:
45 62 """return diffopts with only opted-in features parsed
46 63
47 64 Features:
@@ -51,7 +68,12 b' def difffeatureopts('
51 68 with most diff parsers
52 69 """
53 70
54 def get(key, name=None, getter=ui.configbool, forceplain=None):
71 def get(
72 key: bytes,
73 name: Optional[bytes] = None,
74 getter=ui.configbool,
75 forceplain: Optional[bool] = None,
76 ) -> Any:
55 77 if opts:
56 78 v = opts.get(key)
57 79 # diffopts flags are either None-default (which is passed
General Comments 0
You need to be logged in to leave comments. Login now