# HG changeset patch # User Matt Harbison # Date 2023-01-06 00:53:02 # Node ID 92743e6d1a0c55febc17a0e0b3673abc1801c517 # Parent b1147450c55ca9aaeaa493d1e10a976fe05b1d87 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 : 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. diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -353,11 +353,14 @@ def urlencodenested(params): """ 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: