Use another augmented assignment statement #5642

Closed
opened 2025-12-29 19:30:35 +01:00 by adam · 1 comment
Owner

Originally created by @elfring on GitHub (Nov 10, 2021).

NetBox version

v3.0.9

Feature type

Change to existing functionality

Proposed functionality

👀 Some source code analysis tools can help to find opportunities for improving software components.
💭 I propose to increase the usage of augmented assignment statements accordingly.

diff --git a/netbox/netbox/authentication.py b/netbox/netbox/authentication.py
index 653fad3b0..14a4bcbb7 100644
--- a/netbox/netbox/authentication.py
+++ b/netbox/netbox/authentication.py
@@ -260,7 +260,7 @@ try:
             if (self.settings.FIND_GROUP_PERMS and
                     hasattr(user_obj, "ldap_user") and
                     hasattr(user_obj.ldap_user, "group_names")):
-                permission_filter = permission_filter | Q(groups__name__in=user_obj.ldap_user.group_names)
+                permission_filter |= Q(groups__name__in=user_obj.ldap_user.group_names)
             return permission_filter
 except ModuleNotFoundError:
     pass

Use case

Rationale of the Python enhancement proposal 203 (from 2000-07-13)

Database changes

No response

External dependencies

No response

Originally created by @elfring on GitHub (Nov 10, 2021). ### NetBox version v3.0.9 ### Feature type Change to existing functionality ### Proposed functionality :eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to [increase the usage of augmented assignment statements](https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements "Augmented assignment statements") accordingly. ```diff diff --git a/netbox/netbox/authentication.py b/netbox/netbox/authentication.py index 653fad3b0..14a4bcbb7 100644 --- a/netbox/netbox/authentication.py +++ b/netbox/netbox/authentication.py @@ -260,7 +260,7 @@ try: if (self.settings.FIND_GROUP_PERMS and hasattr(user_obj, "ldap_user") and hasattr(user_obj.ldap_user, "group_names")): - permission_filter = permission_filter | Q(groups__name__in=user_obj.ldap_user.group_names) + permission_filter |= Q(groups__name__in=user_obj.ldap_user.group_names) return permission_filter except ModuleNotFoundError: pass ``` ### Use case [Rationale of the Python enhancement proposal 203](https://www.python.org/dev/peps/pep-0203/#rationale "Proposal for augmented assignments") (from 2000-07-13) ### Database changes _No response_ ### External dependencies _No response_
adam closed this issue 2025-12-29 19:30:35 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 10, 2021):

Thank you for your interest in NetBox. I'm afraid we're not accepting feature requests for minor housekeeping items. As this does not appear to effect any substantial change to NetBox's operation, this issue is being closed.

If you'd like to contribute to NetBox's development, there are plenty issues in need of an owner to consider. Thanks!

@jeremystretch commented on GitHub (Nov 10, 2021): Thank you for your interest in NetBox. I'm afraid we're not accepting feature requests for minor housekeeping items. As this does not appear to effect any substantial change to NetBox's operation, this issue is being closed. If you'd like to contribute to NetBox's development, there are plenty [issues in need of an owner](https://github.com/netbox-community/netbox/issues?q=is%3Aissue+is%3Aopen+label%3A%22status%3A+needs+owner%22) to consider. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5642