comparison mercurial/windows.py @ 48986:d500df2e8034

pytype: disable a few errors about Windows specific module attributes These were flagged by pytype 2022.03.21. Differential Revision: https://phab.mercurial-scm.org/D12401
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 23 Mar 2022 13:51:40 -0400
parents 642e31cb55f0
children 53e9422a9b45
comparison
equal deleted inserted replaced
48985:c75dae6e4ca7 48986:d500df2e8034
674 scope: optionally specify scope for registry lookup, this can be 674 scope: optionally specify scope for registry lookup, this can be
675 a sequence of scopes to look up in order. Default (CURRENT_USER, 675 a sequence of scopes to look up in order. Default (CURRENT_USER,
676 LOCAL_MACHINE). 676 LOCAL_MACHINE).
677 """ 677 """
678 if scope is None: 678 if scope is None:
679 # pytype: disable=module-attr
679 scope = (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE) 680 scope = (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE)
681 # pytype: enable=module-attr
680 elif not isinstance(scope, (list, tuple)): 682 elif not isinstance(scope, (list, tuple)):
681 scope = (scope,) 683 scope = (scope,)
682 for s in scope: 684 for s in scope:
683 try: 685 try:
686 # pytype: disable=module-attr
684 with winreg.OpenKey(s, encoding.strfromlocal(key)) as hkey: 687 with winreg.OpenKey(s, encoding.strfromlocal(key)) as hkey:
688 # pytype: enable=module-attr
685 name = valname and encoding.strfromlocal(valname) or valname 689 name = valname and encoding.strfromlocal(valname) or valname
690 # pytype: disable=module-attr
686 val = winreg.QueryValueEx(hkey, name)[0] 691 val = winreg.QueryValueEx(hkey, name)[0]
692 # pytype: enable=module-attr
693
687 # never let a Unicode string escape into the wild 694 # never let a Unicode string escape into the wild
688 return encoding.unitolocal(val) 695 return encoding.unitolocal(val)
689 except EnvironmentError: 696 except EnvironmentError:
690 pass 697 pass
691 698