Fixing flake8 warnings and errors

flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark

Excluding the benchmark directory (due to protobuf generated files)
Also removing some Python2 specific code
This commit is contained in:
Jacob Alexander
2019-09-26 22:18:28 -07:00
parent 1f0200af9c
commit b3021e4f6b
37 changed files with 536 additions and 452 deletions

View File

@@ -77,7 +77,10 @@ def test_which_reader(addressbook):
addresses.which
@pytest.mark.skipif(capnp.version.LIBCAPNP_VERSION < 5000, reason="Using ints as enums requires v0.5.0+ of the C++ capnp library")
@pytest.mark.skipif(
capnp.version.LIBCAPNP_VERSION < 5000,
reason="Using ints as enums requires v0.5.0+ of the C++ capnp library"
)
def test_enum(addressbook):
addresses = addressbook.AddressBook.new_message()
people = addresses.init('people', 2)
@@ -188,13 +191,8 @@ def test_set_dict_union(addressbook):
assert person.employment.employer.name == 'foo'
try:
basestring # attempt to evaluate basestring
def isstr(s):
return isinstance(s, basestring)
except NameError:
def isstr(s):
return isinstance(s, str)
def isstr(s):
return isinstance(s, str)
def test_to_dict_enum(addressbook):
@@ -227,7 +225,12 @@ def test_to_dict_verbose(addressbook):
def test_to_dict_ordered(addressbook):
person = addressbook.Person.new_message(**{'name': 'Alice', 'phones': [{'type': 'mobile', 'number': '555-1212'}], 'id': 123, 'employment': {'school': 'MIT'}, 'email': 'alice@example.com'})
person = addressbook.Person.new_message(**{
'name': 'Alice',
'phones': [{'type': 'mobile', 'number': '555-1212'}],
'id': 123,
'employment': {'school': 'MIT'}, 'email': 'alice@example.com'
})
if sys.version_info >= (2, 7):
assert list(person.to_dict(ordered=True).keys()) == ['id', 'name', 'email', 'phones', 'employment']
@@ -246,4 +249,4 @@ def test_nested_list(addressbook):
struct.list[1][0] = 2
struct.list[1][1] = 3
assert struct.to_dict()["list"] == [[1], [2,3]]
assert struct.to_dict()["list"] == [[1], [2, 3]]