[tor-commits] [stem/master] Fixing issues caught by pyflakes
atagar at torproject.org
atagar at torproject.org
Thu Jan 10 04:32:06 UTC 2013
commit 4267b6c42a0de9546f664b7498bb3f2ca9b065b2
Author: Damian Johnson <atagar at torproject.org>
Date: Wed Jan 9 20:29:19 2013 -0800
Fixing issues caught by pyflakes
Mostly extra imports, though in one case it caught an error (default arguments
for get_server_descriptors() and get_network_statuses() would cause a
NameError).
---
stem/control.py | 4 ++--
stem/util/system.py | 2 +-
test/check_whitespace.py | 15 ---------------
test/integ/control/controller.py | 12 +++++-------
test/integ/process.py | 1 -
test/settings.cfg | 2 ++
test/unit/control/controller.py | 1 -
.../networkstatus/directory_authority.py | 2 --
test/unit/descriptor/server_descriptor.py | 1 -
test/util.py | 2 --
10 files changed, 10 insertions(+), 32 deletions(-)
diff --git a/stem/control.py b/stem/control.py
index c9d215a..4d3bb52 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -954,7 +954,7 @@ class Controller(BaseController):
if default == UNDEFINED:
raise exc
else:
- if entry is not None:
+ if default is not None:
for entry in default:
yield entry
@@ -1027,7 +1027,7 @@ class Controller(BaseController):
if default == UNDEFINED:
raise exc
else:
- if entry is not None:
+ if default is not None:
for entry in default:
yield entry
diff --git a/stem/util/system.py b/stem/util/system.py
index 91d0e73..a8cecd1 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -28,7 +28,7 @@ import time
import stem.util.proc
-from stem import UNDEFINED, CircStatus
+from stem import UNDEFINED
from stem.util import log
# Mapping of commands to if they're available or not.
diff --git a/test/check_whitespace.py b/test/check_whitespace.py
index 4eca629..a6a9ead 100644
--- a/test/check_whitespace.py
+++ b/test/check_whitespace.py
@@ -179,21 +179,6 @@ def get_issues(base_path = DEFAULT_TARGET):
file_issues.append((index + 1, "contains a windows newline"))
elif content != content.rstrip():
file_issues.append((index + 1, "line has trailing whitespace"))
- elif content == '':
- # empty line, check its indentation against the previous and next line
- # with content
-
- next_indent = 0
-
- for future_index in xrange(index + 1, len(lines)):
- future_whitespace, future_content = re.match("^(\s*)(.*)$", lines[future_index]).groups()
-
- if future_content:
- next_indent = len(future_whitespace)
- break
- else:
- # we had content and it's fine, making a note of its indentation
- prev_indent = len(whitespace)
if file_issues:
issues[file_path] = file_issues
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index aba2c20..bf6b229 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -5,12 +5,10 @@ Integration tests for the stem.control.Controller class.
from __future__ import with_statement
import os
-import re
import shutil
import socket
import tempfile
import threading
-import time
import unittest
import stem.connection
@@ -307,13 +305,13 @@ class TestController(unittest.TestCase):
runner = test.runner.get_runner()
with runner.get_tor_controller() as controller:
- socket = controller.get_socket()
+ control_socket = controller.get_socket()
- if isinstance(socket, stem.socket.ControlPort):
- connection_value = str(socket.get_port())
+ if isinstance(control_socket, stem.socket.ControlPort):
+ connection_value = str(control_socket.get_port())
config_key = "ControlPort"
- elif isinstance(socket, stem.socket.ControlSocketFile):
- connection_value = str(socket.get_socket_path())
+ elif isinstance(control_socket, stem.socket.ControlSocketFile):
+ connection_value = str(control_socket.get_socket_path())
config_key = "ControlSocket"
# successful single query
diff --git a/test/integ/process.py b/test/integ/process.py
index ffc4309..fb9ec9c 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -3,7 +3,6 @@ Tests the stem.process functions with various use cases.
"""
import os
-import shutil
import signal
import subprocess
import time
diff --git a/test/settings.cfg b/test/settings.cfg
index c87781f..9b58f82 100644
--- a/test/settings.cfg
+++ b/test/settings.cfg
@@ -156,4 +156,6 @@ target.torrc RUN_PTRACE => PORT, PTRACE
pyflakes.ignore stem/prereq.py => 'RSA' imported but unused
pyflakes.ignore stem/prereq.py => 'asn1' imported but unused
pyflakes.ignore stem/prereq.py => 'long_to_bytes' imported but unused
+pyflakes.ignore stem/descriptor/__init__.py => redefinition of unused 'OrderedDict' from line 33
+pyflakes.ignore test/unit/response/events.py => 'from stem import *' used; unable to detect undefined names
diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index 488f397..09b0684 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -11,7 +11,6 @@ import stem.version
from stem import InvalidArguments, InvalidRequest, ProtocolError
from stem.control import _parse_circ_path, Controller, EventType
-from stem.response import events
from test import mocking
diff --git a/test/unit/descriptor/networkstatus/directory_authority.py b/test/unit/descriptor/networkstatus/directory_authority.py
index d116b00..eb685df 100644
--- a/test/unit/descriptor/networkstatus/directory_authority.py
+++ b/test/unit/descriptor/networkstatus/directory_authority.py
@@ -4,8 +4,6 @@ Unit tests for the DirectoryAuthority of stem.descriptor.networkstatus.
import unittest
-import test.runner
-
from stem.descriptor.networkstatus import DirectoryAuthority
from test.mocking import get_directory_authority, get_key_certificate, AUTHORITY_HEADER
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index f455eb8..3ea4c5e 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -9,7 +9,6 @@ import unittest
import stem.descriptor.server_descriptor
import stem.exit_policy
import stem.prereq
-import test.runner
from stem.descriptor.server_descriptor import RelayDescriptor, BridgeDescriptor
diff --git a/test/util.py b/test/util.py
index 2613bd5..4035a21 100644
--- a/test/util.py
+++ b/test/util.py
@@ -1,8 +1,6 @@
import socket
import struct
-import test.runner
-
from stem import ProtocolError, SocketError
error_msgs = {
More information about the tor-commits
mailing list