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.
--- 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: