HomePhabricator

typing: rewrite a conditional assignment to unconfuse pytype

Authored by mharbison72.

Description

typing: rewrite a conditional assignment to unconfuse pytype

Otherwise, pytype and PyCharm flags it:

File "/mnt/c/Users/Matt/hg/mercurial/localrepo.py", line 2903, in wlock: No attribute 'held' on _weakref.ReferenceType[nothing] [attribute-error]
  In Optional[Union[Any, _weakref.ReferenceType[nothing]]]
File "/mnt/c/Users/Matt/hg/mercurial/localrepo.py", line 2904, in wlock: No attribute 'lock' on _weakref.ReferenceType[nothing] [attribute-error]
  In Optional[Union[Any, _weakref.ReferenceType[nothing]]]

Differential Revision: https://phab.mercurial-scm.org/D10215