Mercurial > hg
changeset 49863:92743e6d1a0c
typing: disable a bogus attribute-error warning in phabricator
In a local pytype run, this fixes:
File "/mnt/c/Users/Matt/hg/hgext/phabricator.py", line 359, in <lambda>:
No attribute 'items' on bytes [attribute-error]
In Union[Any, bytes]
Called from (traceback):
line 363, in process
The `bytes` case takes the previous `if` branch though.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 05 Jan 2023 19:53:02 -0500 |
parents | b1147450c55c |
children | 5f006f789373 |
files | hgext/phabricator.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/phabricator.py Thu Jan 05 19:47:35 2023 -0500 +++ b/hgext/phabricator.py Thu Jan 05 19:53:02 2023 -0500 @@ -353,11 +353,14 @@ """ flatparams = util.sortdict() - def process(prefix, obj): + def process(prefix: bytes, obj): if isinstance(obj, bool): obj = {True: b'true', False: b'false'}[obj] # Python -> PHP form lister = lambda l: [(b'%d' % k, v) for k, v in enumerate(l)] + # .items() will only be called for a dict type + # pytype: disable=attribute-error items = {list: lister, dict: lambda x: x.items()}.get(type(obj)) + # pytype: enable=attribute-error if items is None: flatparams[prefix] = obj else: