Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/resourceutil.py @ 46783:7fd369644c68 stable
typing: disable a few errors calling py3.7+ functions in resourceutil.py
There's a graceful fallback when these methods are unavailable.
Differential Revision: https://phab.mercurial-scm.org/D10205
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 12 Mar 2021 16:55:18 -0500 |
parents | dd9e28612468 |
children | d4ba4d51f85f |
comparison
equal
deleted
inserted
replaced
46703:ca69e29a2a30 | 46783:7fd369644c68 |
---|---|
68 return resources.open_binary( # pytype: disable=module-attr | 68 return resources.open_binary( # pytype: disable=module-attr |
69 pycompat.sysstr(package), pycompat.sysstr(name) | 69 pycompat.sysstr(package), pycompat.sysstr(name) |
70 ) | 70 ) |
71 | 71 |
72 def is_resource(package, name): | 72 def is_resource(package, name): |
73 return resources.is_resource( | 73 return resources.is_resource( # pytype: disable=module-attr |
74 pycompat.sysstr(package), encoding.strfromlocal(name) | 74 pycompat.sysstr(package), encoding.strfromlocal(name) |
75 ) | 75 ) |
76 | 76 |
77 def contents(package): | 77 def contents(package): |
78 # pytype: disable=module-attr | |
78 for r in resources.contents(pycompat.sysstr(package)): | 79 for r in resources.contents(pycompat.sysstr(package)): |
80 # pytype: enable=module-attr | |
79 yield encoding.strtolocal(r) | 81 yield encoding.strtolocal(r) |
80 | 82 |
81 | 83 |
82 except (ImportError, AttributeError): | 84 except (ImportError, AttributeError): |
83 # importlib.resources was not found (almost definitely because we're on a | 85 # importlib.resources was not found (almost definitely because we're on a |