From 9b6dec95437642c3e662d7addf03633708436fce Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sat, 4 Apr 2020 20:14:43 +1000
Subject: [PATCH] doc: update the documentation for Device.id

Because I spent way too long trying to assign device.id['vendor'] before I
remembered that it doesn't work that way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 libevdev/device.py | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libevdev/device.py b/libevdev/device.py
index 4698580..4b54f44 100644
--- a/libevdev/device.py
+++ b/libevdev/device.py
@@ -284,14 +284,27 @@ class Device(object):
     @property
     def id(self):
         """
-        :returns: A dict with the keys 'bustype', 'vendor', 'product', 'version'.
+        :returns: A dict with the keys ``'bustype'``, ``'vendor'``,
+                  ``'product'``, ``'version'``.
 
         When used as a setter, only existing keys are applied to the
         device. For example, to update the product ID only::
 
                 ctx = Device()
-                id["property"] = 1234
-                ctx.id = id
+                ids = {'product' : 1234}
+                ctx.id = ids
+
+        You must assign a new dictionary to ``id``. Technical limitations
+        prohibit accessing the ``id`` dictionary itself for write access.
+        See this example: ::
+
+                $ ctx = Device()
+                $ ctx.id['vendor'] = 1234
+                $ print(ctx.id['vendor'])
+                0
+                $ ctx.id = {'vendor': 1234}
+                $ print(ctx.id['vendor'])
+                1234
 
         """
         return self._libevdev.id
-- 
GitLab