)
if session:
- cm = contextlib.nullcontext(session)
+ cm: contextlib.AbstractContextManager = contextlib.nullcontext(session)
elif _is_httpx:
cm = httpx.Client(
http1=True, http2=_have_http2, verify=verify, transport=transport
)
(begin_time, expiration) = _compute_times(timeout)
if sock:
- cm = contextlib.nullcontext(sock)
+ cm: contextlib.AbstractContextManager = contextlib.nullcontext(sock)
else:
cm = _make_socket(af, socket.SOCK_DGRAM, source)
with cm as s:
wire = q.to_wire()
(begin_time, expiration) = _compute_times(timeout)
if sock:
- cm = contextlib.nullcontext(sock)
+ cm: contextlib.AbstractContextManager = contextlib.nullcontext(sock)
else:
(af, destination, source) = _destination_and_source(
where, port, source, source_port
if isinstance(f, str):
try:
- cm = open(f)
+ cm: contextlib.AbstractContextManager = open(f)
except OSError:
# /etc/resolv.conf doesn't exist, can't be read, etc.
raise NoResolverConfiguration(f"cannot open {f}")
"""
if isinstance(f, str):
- cm = open(f, "wb")
+ cm: contextlib.AbstractContextManager = open(f, "wb")
else:
cm = contextlib.nullcontext(f)
with cm as f:
if isinstance(f, str):
if filename is None:
filename = f
- cm = open(f)
+ cm: contextlib.AbstractContextManager = open(f)
else:
cm = contextlib.nullcontext(f)
with cm as f: