[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Fixing E713 (test for membership should be 'not in')



commit 67e1c4e740da8b1383716dd52246d133848b12e2
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Aug 16 16:40:44 2014 -0700

    Fixing E713 (test for membership should be 'not in')
    
    Correcting several instances where we do...
    
      if not X in Y:
    
    ... rather than...
    
      if X not in Y:
---
 run_tests.py                            |    4 ++--
 stem/connection.py                      |    2 +-
 stem/control.py                         |    2 +-
 stem/descriptor/export.py               |    2 +-
 stem/descriptor/extrainfo_descriptor.py |   18 +++++++++---------
 stem/descriptor/microdescriptor.py      |    2 +-
 stem/descriptor/networkstatus.py        |   16 ++++++++--------
 stem/descriptor/reader.py               |    2 +-
 stem/descriptor/remote.py               |    6 +++---
 stem/descriptor/router_status_entry.py  |    6 +++---
 stem/descriptor/server_descriptor.py    |    8 ++++----
 stem/exit_policy.py                     |    6 +++---
 stem/interpreter/help.py                |    2 +-
 stem/prereq.py                          |    2 +-
 stem/process.py                         |    4 ++--
 stem/response/events.py                 |   18 +++++++++---------
 stem/response/getconf.py                |    2 +-
 stem/response/protocolinfo.py           |    2 +-
 stem/util/conf.py                       |    2 +-
 stem/util/connection.py                 |    2 +-
 stem/util/enum.py                       |    4 ++--
 stem/util/system.py                     |    2 +-
 stem/version.py                         |    2 +-
 test/integ/connection/authentication.py |    4 ++--
 test/integ/control/controller.py        |    2 +-
 test/integ/descriptor/networkstatus.py  |    4 ++--
 test/integ/util/connection.py           |    2 +-
 test/integ/util/proc.py                 |    2 +-
 test/mocking.py                         |    2 +-
 test/runner.py                          |    2 +-
 test/unit/connection/connect.py         |    2 +-
 31 files changed, 68 insertions(+), 68 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 2524756..3c91513 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -364,7 +364,7 @@ def _get_args(argv):
         raise ValueError("No targets provided")
 
       for target in integ_targets:
-        if not target in Target:
+        if target not in Target:
           raise ValueError("Invalid integration target: %s" % target)
         elif target in all_run_targets:
           run_targets.append(target)
@@ -384,7 +384,7 @@ def _get_args(argv):
     elif opt in ("-l", "--log"):
       arg = arg.upper()
 
-      if not arg in stem.util.log.LOG_VALUES:
+      if arg not in stem.util.log.LOG_VALUES:
         raise ValueError(LOG_TYPE_ERROR % arg)
 
       args['logging_runlevel'] = arg
diff --git a/stem/connection.py b/stem/connection.py
index 4bfcd5c..cc28fa5 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -555,7 +555,7 @@ def authenticate(controller, password = None, chroot_path = None, protocolinfo_r
 
   # iterating over AuthMethods so we can try them in this order
   for auth_type in (AuthMethod.NONE, AuthMethod.PASSWORD, AuthMethod.SAFECOOKIE, AuthMethod.COOKIE):
-    if not auth_type in auth_methods:
+    if auth_type not in auth_methods:
       continue
 
     try:
diff --git a/stem/control.py b/stem/control.py
index b8cff59..4b70240 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1096,7 +1096,7 @@ class Controller(BaseController):
         for listener in self.get_info(query).split():
           if not (listener.startswith('"') and listener.endswith('"')):
             raise stem.ProtocolError("'GETINFO %s' responses are expected to be quoted: %s" % (query, listener))
-          elif not ':' in listener:
+          elif ':' not in listener:
             raise stem.ProtocolError("'GETINFO %s' had a listener without a colon: %s" % (query, listener))
 
           listener = listener[1:-1]  # strip quotes
diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index 09454c5..fce6eb0 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -81,7 +81,7 @@ def export_csv_file(output_file, descriptors, included_fields = (), excluded_fie
 
   if included_fields:
     for field in included_fields:
-      if not field in desc_attr:
+      if field not in desc_attr:
         raise ValueError("%s does not have a '%s' attribute, valid fields are: %s" % (descriptor_type_label, field, ', '.join(desc_attr)))
   else:
     included_fields = [attr for attr in desc_attr if not attr.startswith('_')]
diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index c6d2194..0aa7724 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -426,7 +426,7 @@ class ExtraInfoDescriptor(Descriptor):
 
     if validate:
       for keyword in self._required_fields():
-        if not keyword in entries:
+        if keyword not in entries:
           raise ValueError("Extra-info descriptor must have a '%s' entry" % keyword)
 
       for keyword in self._required_fields() + SINGLE_FIELDS:
@@ -506,7 +506,7 @@ class ExtraInfoDescriptor(Descriptor):
         for transport_value, _, _ in values:
           name, address, port, args = None, None, None, None
 
-          if not ' ' in transport_value:
+          if ' ' not in transport_value:
             # scrubbed
             name = transport_value
           else:
@@ -520,7 +520,7 @@ class ExtraInfoDescriptor(Descriptor):
 
             if len(value_comp) < 2:
               raise ValueError('Transport line is missing its address:port value: %s' % line)
-            elif not ':' in value_comp[1]:
+            elif ':' not in value_comp[1]:
               raise ValueError("Transport line's address:port entry is missing a colon: %s" % line)
             else:
               address, port_str = value_comp[1].split(':', 1)
@@ -566,7 +566,7 @@ class ExtraInfoDescriptor(Descriptor):
 
         if value:
           for entry in value.split(','):
-            if not '=' in entry:
+            if '=' not in entry:
               if validate:
                 raise ValueError(error_msg)
               else:
@@ -740,7 +740,7 @@ class ExtraInfoDescriptor(Descriptor):
 
         if value:
           for entry in value.split(','):
-            if not '=' in entry:
+            if '=' not in entry:
               if validate:
                 raise ValueError(error_msg)
               else:
@@ -775,7 +775,7 @@ class ExtraInfoDescriptor(Descriptor):
 
         if value:
           for entry in value.split(','):
-            if not '=' in entry:
+            if '=' not in entry:
               if validate:
                 raise ValueError(error_msg)
               else:
@@ -807,7 +807,7 @@ class ExtraInfoDescriptor(Descriptor):
 
         if value:
           for entry in value.split(','):
-            if not '=' in entry:
+            if '=' not in entry:
               raise stem.ProtocolError("The bridge-ip-versions should be a comma separated listing of '<protocol>=<count>' mappings: %s" % line)
 
             protocol, count = entry.split('=', 1)
@@ -821,7 +821,7 @@ class ExtraInfoDescriptor(Descriptor):
 
         if value:
           for entry in value.split(','):
-            if not '=' in entry:
+            if '=' not in entry:
               raise stem.ProtocolError("The bridge-ip-transports should be a comma separated listing of '<protocol>=<count>' mappings: %s" % line)
 
             protocol, count = entry.split('=', 1)
@@ -939,7 +939,7 @@ class BridgeExtraInfoDescriptor(ExtraInfoDescriptor):
       'router-digest',
     ]
 
-    return tuple(included_fields + [f for f in REQUIRED_FIELDS if not f in excluded_fields])
+    return tuple(included_fields + [f for f in REQUIRED_FIELDS if f not in excluded_fields])
 
   def _last_keyword(self):
     return None
diff --git a/stem/descriptor/microdescriptor.py b/stem/descriptor/microdescriptor.py
index e29ec71..addb495 100644
--- a/stem/descriptor/microdescriptor.py
+++ b/stem/descriptor/microdescriptor.py
@@ -295,7 +295,7 @@ class Microdescriptor(Descriptor):
     """
 
     for keyword in REQUIRED_FIELDS:
-      if not keyword in entries:
+      if keyword not in entries:
         raise ValueError("Microdescriptor must have a '%s' entry" % keyword)
 
     for keyword in SINGLE_FIELDS:
diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py
index 5af9d02..115f07b 100644
--- a/stem/descriptor/networkstatus.py
+++ b/stem/descriptor/networkstatus.py
@@ -442,7 +442,7 @@ class NetworkStatusDocumentV2(NetworkStatusDocument):
   def _check_constraints(self, entries):
     required_fields = [field for (field, is_mandatory) in NETWORK_STATUS_V2_FIELDS if is_mandatory]
     for keyword in required_fields:
-      if not keyword in entries:
+      if keyword not in entries:
         raise ValueError("Network status document (v2) must have a '%s' line:\n%s" % (keyword, str(self)))
 
     # all recognized fields can only appear once
@@ -749,7 +749,7 @@ class _DocumentHeader(object):
 
         if value:
           for entry in value.split(' '):
-            if not '=' in entry:
+            if '=' not in entry:
               if not validate:
                 continue
 
@@ -894,7 +894,7 @@ class _DocumentFooter(object):
         self.bandwidth_weights = _parse_int_mappings(keyword, value, validate)
       elif keyword == 'directory-signature':
         for sig_value, block_type, block_contents in values:
-          if not sig_value.count(' ') in (1, 2):
+          if sig_value.count(' ') not in (1, 2):
             if not validate:
               continue
 
@@ -931,7 +931,7 @@ def _check_for_missing_and_disallowed_fields(header, entries, fields):
   for field, in_votes, in_consensus, mandatory in fields:
     if mandatory and ((header.is_consensus and in_consensus) or (header.is_vote and in_votes)):
       # mandatory field, check that we have it
-      if not field in entries.keys():
+      if field not in entries.keys():
         missing_fields.append(field)
     elif (header.is_consensus and not in_consensus) or (header.is_vote and not in_votes):
       # field we shouldn't have, check that we don't
@@ -983,7 +983,7 @@ def _parse_int_mappings(keyword, value, validate):
   results, seen_keys = {}, []
   for entry in value.split(' '):
     try:
-      if not '=' in entry:
+      if '=' not in entry:
         raise ValueError("must only have 'key=value' entries")
 
       entry_key, entry_value = entry.split('=', 1)
@@ -1133,7 +1133,7 @@ class DirectoryAuthority(Descriptor):
         excluded_fields += ['legacy-dir-key']
 
       for keyword in required_fields:
-        if not keyword in entries:
+        if keyword not in entries:
           raise ValueError("Authority entries must have a '%s' line:\n%s" % (keyword, content))
 
       for keyword in entries:
@@ -1294,7 +1294,7 @@ class KeyCertificate(Descriptor):
       # appear once
 
       for keyword, is_mandatory in KEY_CERTIFICATE_PARAMS:
-        if is_mandatory and not keyword in entries:
+        if is_mandatory and keyword not in entries:
           raise ValueError("Key certificates must have a '%s' line:\n%s" % (keyword, content))
 
         entry_count = len(entries.get(keyword, []))
@@ -1321,7 +1321,7 @@ class KeyCertificate(Descriptor):
       elif keyword == 'dir-address':
         # "dir-address" IPPort
 
-        if not ':' in value:
+        if ':' not in value:
           if not validate:
             continue
 
diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index 05c7533..3b2770a 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -180,7 +180,7 @@ def load_processed_files(path):
       if not line:
         continue  # skip blank lines
 
-      if not ' ' in line:
+      if ' ' not in line:
         raise TypeError('Malformed line: %s' % line)
 
       path, timestamp = line.rsplit(' ', 1)
diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index da58f2b..eccf2d1 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -550,7 +550,7 @@ class DescriptorDownloader(object):
 
     resource = '/tor/status-vote/current/authority'
 
-    if not 'endpoint' in query_args:
+    if 'endpoint' not in query_args:
       query_args['endpoints'] = [(authority.address, authority.dir_port)]
 
     return self.query(resource + '.z', **query_args)
@@ -605,10 +605,10 @@ class DescriptorDownloader(object):
     args = dict(self._default_args)
     args.update(query_args)
 
-    if not 'endpoints' in args:
+    if 'endpoints' not in args:
       args['endpoints'] = self._endpoints
 
-    if not 'fall_back_to_authority' in args:
+    if 'fall_back_to_authority' not in args:
       args['fall_back_to_authority'] = True
 
     return Query(
diff --git a/stem/descriptor/router_status_entry.py b/stem/descriptor/router_status_entry.py
index ee18705..27ff203 100644
--- a/stem/descriptor/router_status_entry.py
+++ b/stem/descriptor/router_status_entry.py
@@ -191,7 +191,7 @@ class RouterStatusEntry(Descriptor):
     """
 
     for keyword in self._required_fields():
-      if not keyword in entries:
+      if keyword not in entries:
         raise ValueError("%s must have a '%s' line:\n%s" % (self._name(True), keyword, str(self)))
 
     for keyword in self._single_fields():
@@ -532,7 +532,7 @@ def _parse_a_line(desc, value, validate):
   # "a" SP address ":" portlist
   # example: a [2001:888:2133:0:82:94:251:204]:9001
 
-  if not ':' in value:
+  if ':' not in value:
     if not validate:
       return
 
@@ -681,7 +681,7 @@ def _parse_m_line(desc, value, validate):
   hashes = {}
 
   for entry in m_comp[1:]:
-    if not '=' in entry:
+    if '=' not in entry:
       if not validate:
         continue
 
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 064b287..1b34c58 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -482,7 +482,7 @@ class ServerDescriptor(Descriptor):
       elif keyword == 'hibernating':
         # "hibernating" 0|1 (in practice only set if one)
 
-        if validate and not value in ('0', '1'):
+        if validate and value not in ('0', '1'):
           raise ValueError('Hibernating line had an invalid value, must be zero or one: %s' % value)
 
         self.hibernating = value == '1'
@@ -545,7 +545,7 @@ class ServerDescriptor(Descriptor):
         for entry in or_address_entries:
           line = '%s %s' % (keyword, entry)
 
-          if not ':' in entry:
+          if ':' not in entry:
             if not validate:
               continue
             else:
@@ -613,7 +613,7 @@ class ServerDescriptor(Descriptor):
     """
 
     for keyword in self._required_fields():
-      if not keyword in entries:
+      if keyword not in entries:
         raise ValueError("Descriptor must have a '%s' entry" % keyword)
 
     for keyword in self._single_fields():
@@ -947,7 +947,7 @@ class BridgeDescriptor(ServerDescriptor):
       'router-digest',
     ]
 
-    return tuple(included_fields + [f for f in REQUIRED_FIELDS if not f in excluded_fields])
+    return tuple(included_fields + [f for f in REQUIRED_FIELDS if f not in excluded_fields])
 
   def _single_fields(self):
     return self._required_fields() + SINGLE_FIELDS
diff --git a/stem/exit_policy.py b/stem/exit_policy.py
index 2051995..e779562 100644
--- a/stem/exit_policy.py
+++ b/stem/exit_policy.py
@@ -116,7 +116,7 @@ def get_config_policy(rules):
     if not rule:
       continue
 
-    if not ':' in rule:
+    if ':' not in rule:
       rule = "%s:*" % rule
 
     if 'private' in rule:
@@ -211,7 +211,7 @@ class ExitPolicy(object):
     for rule in self._get_rules():
       if rule.is_accept:
         for port in xrange(rule.min_port, rule.max_port + 1):
-          if not port in rejected_ports:
+          if port not in rejected_ports:
             return True
       elif rule.is_address_wildcard():
         if rule.is_port_wildcard():
@@ -502,7 +502,7 @@ class ExitPolicyRule(object):
 
     exitpattern = exitpattern[1:]
 
-    if not ':' in exitpattern:
+    if ':' not in exitpattern:
       raise ValueError("An exitpattern must be of the form 'addrspec:portspec': %s" % rule)
 
     self.address = None
diff --git a/stem/interpreter/help.py b/stem/interpreter/help.py
index e17fe3f..983da3e 100644
--- a/stem/interpreter/help.py
+++ b/stem/interpreter/help.py
@@ -59,7 +59,7 @@ def _response(controller, arg, config):
 
   usage_info = config.get('help.usage', {})
 
-  if not arg in usage_info:
+  if arg not in usage_info:
     return format("No help information available for '%s'..." % arg, *ERROR_OUTPUT)
 
   output = format(usage_info[arg] + '\n', *BOLD_OUTPUT)
diff --git a/stem/prereq.py b/stem/prereq.py
index 2f649e2..46763fb 100644
--- a/stem/prereq.py
+++ b/stem/prereq.py
@@ -124,7 +124,7 @@ def is_mock_available():
 
     # check for mock's new_callable argument for patch() which was introduced in version 0.8.0
 
-    if not 'new_callable' in inspect.getargspec(mock.patch).args:
+    if 'new_callable' not in inspect.getargspec(mock.patch).args:
       raise ImportError()
 
     return True
diff --git a/stem/process.py b/stem/process.py
index c9fe863..2886270 100644
--- a/stem/process.py
+++ b/stem/process.py
@@ -83,7 +83,7 @@ def launch_tor(tor_cmd = 'tor', args = None, torrc_path = None, completion_perce
     raise OSError("'%s' isn't available on your system. Maybe it's not in your PATH?" % tor_cmd)
 
   # double check that we have a torrc to work with
-  if not torrc_path in (None, NO_TORRC) and not os.path.exists(torrc_path):
+  if torrc_path not in (None, NO_TORRC) and not os.path.exists(torrc_path):
     raise OSError("torrc doesn't exist (%s)" % torrc_path)
 
   # starts a tor subprocess, raising an OSError if it fails
@@ -150,7 +150,7 @@ def launch_tor(tor_cmd = 'tor', args = None, torrc_path = None, completion_perce
       elif problem_match:
         runlevel, msg = problem_match.groups()
 
-        if not 'see warnings above' in msg:
+        if 'see warnings above' not in msg:
           if ': ' in msg:
             msg = msg.split(': ')[-1].strip()
 
diff --git a/stem/response/events.py b/stem/response/events.py
index 582eb22..0065d68 100644
--- a/stem/response/events.py
+++ b/stem/response/events.py
@@ -146,7 +146,7 @@ class Event(stem.response.ControlMessage):
         attr_values = [attr_values]
 
       for value in attr_values:
-        if not value in attr_enum:
+        if value not in attr_enum:
           log_id = 'event.%s.unknown_%s.%s' % (self.type.lower(), attr, value)
           unrecognized_msg = "%s event had an unrecognized %s (%s). Maybe a new addition to the control protocol? Full Event: '%s'" % (self.type, attr, value, self)
           log.log_once(log_id, log.INFO, unrecognized_msg)
@@ -227,7 +227,7 @@ class AuthDirNewDescEvent(Event):
 
     if len(lines) < 5:
       raise stem.ProtocolError("AUTHDIR_NEWDESCS events must contain lines for at least the type, action, message, descriptor, and terminating 'OK'")
-    elif not lines[-1] == 'OK':
+    elif lines[-1] != 'OK':
       raise stem.ProtocolError("AUTHDIR_NEWDESCS doesn't end with an 'OK'")
 
     self.action = lines[1]
@@ -493,7 +493,7 @@ class ClientsSeenEvent(Event):
       locale_to_count = {}
 
       for entry in self.locales.split(','):
-        if not '=' in entry:
+        if '=' not in entry:
           raise stem.ProtocolError("The CLIENTS_SEEN's CountrySummary should be a comma separated listing of '<locale>=<count>' mappings: %s" % self)
 
         locale, count = entry.split('=', 1)
@@ -513,7 +513,7 @@ class ClientsSeenEvent(Event):
       protocol_to_count = {}
 
       for entry in self.ip_versions.split(','):
-        if not '=' in entry:
+        if '=' not in entry:
           raise stem.ProtocolError("The CLIENTS_SEEN's IPVersions should be a comma separated listing of '<protocol>=<count>' mappings: %s" % self)
 
         protocol, count = entry.split('=', 1)
@@ -779,7 +779,7 @@ class ORConnEvent(Event):
       self.endpoint_fingerprint, self.endpoint_nickname = \
         stem.control._parse_circ_entry(self.endpoint)
     except stem.ProtocolError:
-      if not ':' in self.endpoint:
+      if ':' not in self.endpoint:
         raise stem.ProtocolError("ORCONN endpoint is neither a relay nor 'address:port': %s" % self)
 
       address, port = self.endpoint.split(':', 1)
@@ -903,7 +903,7 @@ class StreamEvent(Event):
     if self.target is None:
       raise stem.ProtocolError("STREAM event didn't have a target: %s" % self)
     else:
-      if not ':' in self.target:
+      if ':' not in self.target:
         raise stem.ProtocolError("Target location must be of the form 'address:port': %s" % self)
 
       address, port = self.target.rsplit(':', 1)
@@ -918,7 +918,7 @@ class StreamEvent(Event):
       self.source_address = None
       self.source_port = None
     else:
-      if not ':' in self.source_addr:
+      if ':' not in self.source_addr:
         raise stem.ProtocolError("Source location must be of the form 'address:port': %s" % self)
 
       address, port = self.source_addr.split(':', 1)
@@ -987,7 +987,7 @@ class TransportLaunchedEvent(Event):
   _VERSION_ADDED = stem.version.Requirement.EVENT_TRANSPORT_LAUNCHED
 
   def _parse(self):
-    if not self.type in ('server', 'client'):
+    if self.type not in ('server', 'client'):
       raise stem.ProtocolError("Transport type should either be 'server' or 'client': %s" % self)
 
     if not connection.is_valid_ipv4_address(self.address) and \
@@ -1205,7 +1205,7 @@ def _parse_cell_type_mapping(mapping):
   results = {}
 
   for entry in mapping.split(','):
-    if not ':' in entry:
+    if ':' not in entry:
       raise stem.ProtocolError("Mappings are expected to be of the form 'key:value', got '%s': %s" % (entry, mapping))
 
     key, value = entry.split(':', 1)
diff --git a/stem/response/getconf.py b/stem/response/getconf.py
index 72f91af..c203ae9 100644
--- a/stem/response/getconf.py
+++ b/stem/response/getconf.py
@@ -48,7 +48,7 @@ class GetConfResponse(stem.response.ControlMessage):
       else:
         key, value = (line.pop(), None)
 
-      if not key in self.entries:
+      if key not in self.entries:
         self.entries[key] = []
 
       if value is not None:
diff --git a/stem/response/protocolinfo.py b/stem/response/protocolinfo.py
index 82e5ec0..bbc2a1f 100644
--- a/stem/response/protocolinfo.py
+++ b/stem/response/protocolinfo.py
@@ -97,7 +97,7 @@ class ProtocolInfoResponse(stem.response.ControlMessage):
 
             # our auth_methods should have a single AuthMethod.UNKNOWN entry if
             # any unknown authentication methods exist
-            if not AuthMethod.UNKNOWN in auth_methods:
+            if AuthMethod.UNKNOWN not in auth_methods:
               auth_methods.append(AuthMethod.UNKNOWN)
 
         # parse optional COOKIEFILE mapping (quoted and can have escapes)
diff --git a/stem/util/conf.py b/stem/util/conf.py
index 18b0df4..c96aa88 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -236,7 +236,7 @@ def get_config(handle):
   :param str handle: unique identifier used to access this config instance
   """
 
-  if not handle in CONFS:
+  if handle not in CONFS:
     CONFS[handle] = Config()
 
   return CONFS[handle]
diff --git a/stem/util/connection.py b/stem/util/connection.py
index 5dce161..461f40a 100644
--- a/stem/util/connection.py
+++ b/stem/util/connection.py
@@ -367,7 +367,7 @@ def is_valid_ipv6_address(address, allow_brackets = False):
 
   if colon_count > 7:
     return False  # too many groups
-  elif colon_count != 7 and not '::' in address:
+  elif colon_count != 7 and '::' not in address:
     return False  # not enough groups and none are collapsed
   elif address.count('::') > 1 or ':::' in address:
     return False  # multiple groupings of zeros can't be collapsed
diff --git a/stem/util/enum.py b/stem/util/enum.py
index 1500a43..4a86fc5 100644
--- a/stem/util/enum.py
+++ b/stem/util/enum.py
@@ -121,7 +121,7 @@ class Enum(object):
     :raises: **ValueError** if no such element exists
     """
 
-    if not value in self._values:
+    if value not in self._values:
       raise ValueError('No such enumeration exists: %s (options: %s)' % (value, ', '.join(self._values)))
 
     next_index = (self._values.index(value) + 1) % len(self._values)
@@ -138,7 +138,7 @@ class Enum(object):
     :raises: **ValueError** if no such element exists
     """
 
-    if not value in self._values:
+    if value not in self._values:
       raise ValueError('No such enumeration exists: %s (options: %s)' % (value, ', '.join(self._values)))
 
     prev_index = (self._values.index(value) - 1) % len(self._values)
diff --git a/stem/util/system.py b/stem/util/system.py
index d24d34b..b42a03f 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -640,7 +640,7 @@ def get_cwd(pid):
       # p2683
       # n/proc/2683/cwd (readlink: Permission denied)
 
-      if not ' ' in lsof_result:
+      if ' ' not in lsof_result:
         return lsof_result
     else:
       log.debug('%s we got unexpected output from lsof: %s' % (logging_prefix, results))
diff --git a/stem/version.py b/stem/version.py
index a772e7c..b5b1151 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -90,7 +90,7 @@ def get_system_tor_version(tor_cmd = 'tor'):
   :raises: **IOError** if unable to query or parse the version
   """
 
-  if not tor_cmd in VERSION_CACHE:
+  if tor_cmd not in VERSION_CACHE:
     version_cmd = '%s --version' % tor_cmd
 
     try:
diff --git a/test/integ/connection/authentication.py b/test/integ/connection/authentication.py
index 308f18a..816e671 100644
--- a/test/integ/connection/authentication.py
+++ b/test/integ/connection/authentication.py
@@ -183,7 +183,7 @@ class TestAuthenticate(unittest.TestCase):
 
     runner = test.runner.get_runner()
     tor_options = runner.get_options()
-    is_password_only = test.runner.Torrc.PASSWORD in tor_options and not test.runner.Torrc.COOKIE in tor_options
+    is_password_only = test.runner.Torrc.PASSWORD in tor_options and test.runner.Torrc.COOKIE not in tor_options
 
     # tests without a password
     with runner.get_tor_socket(False) as control_socket:
@@ -218,7 +218,7 @@ class TestAuthenticate(unittest.TestCase):
 
     runner = test.runner.get_runner()
     tor_options = runner.get_options()
-    is_cookie_only = test.runner.Torrc.COOKIE in tor_options and not test.runner.Torrc.PASSWORD in tor_options
+    is_cookie_only = test.runner.Torrc.COOKIE in tor_options and test.runner.Torrc.PASSWORD not in tor_options
 
     # test both cookie authentication mechanisms
     with runner.get_tor_socket(False) as control_socket:
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index c428f25..c2c1d91 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -232,7 +232,7 @@ class TestController(unittest.TestCase):
 
       tor_options = test.runner.get_runner().get_options()
 
-      if not test.runner.Torrc.COOKIE in tor_options:
+      if test.runner.Torrc.COOKIE not in tor_options:
         controller.connect()
 
         if test.runner.Torrc.PASSWORD in tor_options:
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index 83a3ff6..8172fb4 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -44,7 +44,7 @@ class TestNetworkStatus(unittest.TestCase):
         # TODO: this should be a 'new capability' check later rather than
         # failing the tests
         for flag in router.flags:
-          if not flag in stem.Flag:
+          if flag not in stem.Flag:
             raise ValueError('Unrecognized flag type: %s, found on relay %s (%s)' % (flag, router.fingerprint, router.nickname))
 
         unrecognized_lines = router.get_unrecognized_lines()
@@ -85,7 +85,7 @@ class TestNetworkStatus(unittest.TestCase):
         # TODO: this should be a 'new capability' check later rather than
         # failing the tests
         for flag in router.flags:
-          if not flag in stem.Flag:
+          if flag not in stem.Flag:
             raise ValueError('Unrecognized flag type: %s, found on microdescriptor relay %s (%s)' % (flag, router.fingerprint, router.nickname))
 
         unrecognized_lines = router.get_unrecognized_lines()
diff --git a/test/integ/util/connection.py b/test/integ/util/connection.py
index 4c05f74..8883be2 100644
--- a/test/integ/util/connection.py
+++ b/test/integ/util/connection.py
@@ -14,7 +14,7 @@ class TestConnection(unittest.TestCase):
   def test_get_connections(self):
     runner = test.runner.get_runner()
 
-    if not test.runner.Torrc.PORT in runner.get_options():
+    if test.runner.Torrc.PORT not in runner.get_options():
       test.runner.skip(self, '(no control port)')
       return
     elif not test.runner.get_runner().is_ptraceable():
diff --git a/test/integ/util/proc.py b/test/integ/util/proc.py
index 4a43e84..8b76dd6 100644
--- a/test/integ/util/proc.py
+++ b/test/integ/util/proc.py
@@ -84,7 +84,7 @@ class TestProc(unittest.TestCase):
     if not proc.is_available():
       test.runner.skip(self, '(proc unavailable)')
       return
-    elif not test.runner.Torrc.PORT in runner.get_options():
+    elif test.runner.Torrc.PORT not in runner.get_options():
       test.runner.skip(self, '(no control port)')
       return
     elif not test.runner.get_runner().is_ptraceable():
diff --git a/test/mocking.py b/test/mocking.py
index 057541d..e473058 100644
--- a/test/mocking.py
+++ b/test/mocking.py
@@ -211,7 +211,7 @@ def get_all_combinations(attr, include_empty = False):
       # deduplicate, sort, and only provide if we haven't seen it yet
       item = tuple(sorted(set(item)))
 
-      if not item in seen:
+      if item not in seen:
         seen.add(item)
         yield item
 
diff --git a/test/runner.py b/test/runner.py
index 07cbd34..1b55da3 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -156,7 +156,7 @@ def require_online(test_case):
   :returns: True if test should be skipped, False otherwise
   """
 
-  if not Target.ONLINE in get_runner().attribute_targets:
+  if Target.ONLINE not in get_runner().attribute_targets:
     skip(test_case, '(requires online target)')
     return True
 
diff --git a/test/unit/connection/connect.py b/test/unit/connection/connect.py
index 503ad6f..95edea0 100644
--- a/test/unit/connection/connect.py
+++ b/test/unit/connection/connect.py
@@ -137,5 +137,5 @@ class TestConnect(unittest.TestCase):
     stdout_output = stdout_mock.getvalue()
     stdout_mock.truncate(0)
 
-    if not msg in stdout_output:
+    if msg not in stdout_output:
       self.fail("Expected...\n\n%s\n\n... which couldn't be found in...\n\n%s" % (msg, stdout_output))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits