Skip to content
Browse files

target: allow driver bindings by class name

We already allow class name strings in get_driver and similar, so we
should also allow it in the binding dict for consistency. In the longer
term, this should help to reduce the amount of required imports just for
binding to the correct types.

Signed-off-by: Jan Luebbe <>
  • Loading branch information...
jluebbe committed Oct 8, 2019
1 parent df45d23 commit 53b4b34bad8f1c3b70abcd83523231cbbda8d589
Showing with 7 additions and 1 deletion.
  1. +3 −0 CHANGES.rst
  2. +4 −1 labgrid/
@@ -29,6 +29,9 @@ New Features in 0.3.0
- The coordinator now updates the resource acquired state at the exporter.
Accordingly, the exporter now starts ser2net only when a resources is
aquired. Furthermore, resource conflicts between places are now detected.
- The binding dictionary can now supports type name strings in addition to the
types themselves, avoiding the need to import a specific protocol or driver
in some cases.

Breaking changes in 0.3.0
@@ -312,6 +312,9 @@ def bind_driver(self, client):
errors = []
suppliers = []
for requirement in requirements:
# convert class name string to classes
if isinstance(requirement, str):
requirement = self._class_from_string(requirement)
if issubclass(requirement, Resource):
@@ -456,4 +459,4 @@ def _class_from_string(self, string: str):
return self._lookup_table[string]
except KeyError:
raise KeyError("No such driver/resource/protocol in lookup table, perhaps not bound?")
raise KeyError("No driver/resource/protocol of type '{}' in lookup table, perhaps not bound?".format(string))

0 comments on commit 53b4b34

Please sign in to comment.
You can’t perform that action at this time.