# HG changeset patch # User Matt Harbison # Date 2023-01-05 22:28:33 # Node ID 40d3ee570d83e55c1117eee9f07784a5ecd40248 # Parent 36afe74e443973b3c8720abfc6590351dd23723a watchman: refactor transport connecting to unconfuse pytype Pytype sees `self.proc` as potentially `None` here, even though it's set by the `_connect()` logic. Instead of asserting, simply use the process returned by that method (which it sets into `self.proc` before returning, so there's no functional change here). diff --git a/hgext/fsmonitor/pywatchman/__init__.py b/hgext/fsmonitor/pywatchman/__init__.py --- a/hgext/fsmonitor/pywatchman/__init__.py +++ b/hgext/fsmonitor/pywatchman/__init__.py @@ -689,9 +689,9 @@ class CLIProcessTransport(Transport): if self.closed: self.close() self.closed = False - self._connect() - res = self.proc.stdin.write(data) - self.proc.stdin.close() + proc = self._connect() + res = proc.stdin.write(data) + proc.stdin.close() self.closed = True return res