]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Use `()` and `{}` instead of `list()` and `dict()`
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Fri, 24 Sep 2021 21:31:25 +0000 (23:31 +0200)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sat, 26 Feb 2022 15:51:05 +0000 (16:51 +0100)
This fixes a DeepSource alert:

Consider using literal syntax to create the data structure

Using the literal syntax can give minor performance bumps compared to
using function calls to create dict, list and tuple.

This is because here, the name dict must be looked up in the global
scope in case it has been rebound. Same goes for the other two types
list() and tuple().

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
trojans/tncc-emulate.py

index 0c918a64f0627f50b8974a17f6b73368368fe243..d80abe54b665ed49ba27d88ceff0036a9bf0fa63 100755 (executable)
@@ -161,7 +161,7 @@ def decode_0ce7(buf, indent):
 # 0cf0 - encapsulation
 def decode_0cf0(buf, indent):
     logging.debug('%scmd 0cf0 (encapsulation) %d bytes', indent, len(buf))
-    ret = dict()
+    ret = {}
     cmd, _, out = decode_packet(buf, indent + "  ")
     ret[cmd] = out
     return ret
@@ -274,7 +274,7 @@ class x509cert:
 
     @staticmethod
     def decode_names(names):
-        ret = dict()
+        ret = {}
         for name in names.chosen:
             for attr in name:
                 type_dotted = attr['type'].dotted    # dotted-quad value (e.g. '2.5.4.10' = organization)
@@ -353,8 +353,8 @@ class tncc:
         self.cj.set_cookie(cookie)
 
     def parse_response(self):
-        # Read in key/token fields in HTTP response
-        response = dict()
+        # Read in key/token fields in HTTP responsedict
+        response = {}
         last_key = ''
         for line in self.r.readlines():
             line = line.strip().decode()
@@ -385,7 +385,7 @@ class tncc:
                         if key.lower() == 'value':
                             # It's made up of a bunch of key=value pairs separated
                             # by semicolons
-                            d = dict()
+                            d = {}
                             for field in value.split(';'):
                                 field = field.strip()
                                 try: