#28922·ruff

B018: useless-expression one more example to document

Author: spaceoneCreated Sep 26, 2026Updated Sep 27, 2026
Labelsruleneeds-decision

The current docs specify as fix one should assign the thing to a _ variable. For the following case the following fix suits better and could be documented:

diff
-        try:
-            self._ldap_conn
-        except AttributeError:
+        if not hasattr(self, '_ldap_conn'):