Skip to content

Commit

Permalink
remote/client: provide default for ClientSession.env to make it optional
Browse files Browse the repository at this point in the history
The Environment was always optional. Before users of ClientSession had
to pass an explicit None for this attribute. While we're changing the
ClientSession for gRPC anyway, let's make env really optional.

This again allows us to make start_session()'s extra argument optional,
too. It is used to pass extra arguments to the ClientSession, which
means it can be an empty dictionary now.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
  • Loading branch information
Bastian-Krause committed Aug 13, 2024
1 parent 0e1e4fb commit 545d240
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ClientSession:

address = attr.ib(validator=attr.validators.instance_of(str))
loop = attr.ib(validator=attr.validators.instance_of(asyncio.BaseEventLoop))
env = attr.ib(validator=attr.validators.optional(attr.validators.instance_of(Environment)))
env = attr.ib(default=None, validator=attr.validators.optional(attr.validators.instance_of(Environment)))
role = attr.ib(default=None, validator=attr.validators.optional(attr.validators.instance_of(str)))
prog = attr.ib(default=None, validator=attr.validators.optional(attr.validators.instance_of(str)))
args = attr.ib(default=None, validator=attr.validators.optional(attr.validators.instance_of(argparse.Namespace)))
Expand Down Expand Up @@ -1566,9 +1566,12 @@ def ensure_event_loop(external_loop=None):
return loop


def start_session(address, extra, debug=False, loop=None):
def start_session(address, extra=None, debug=False, loop=None):
loop = ensure_event_loop(loop)

if extra is None:
extra = {}

if debug:
loop.set_debug(True)

Expand Down

0 comments on commit 545d240

Please sign in to comment.