Fix some linter errors

This commit is contained in:
Omar Sandoval 2019-04-11 15:51:20 -07:00
parent b86fdf6e5c
commit 435640faf6
12 changed files with 15 additions and 23 deletions

View File

@ -10,7 +10,7 @@ Linux block layer, including disks (``struct gendisk``) and partitions
(``struct hd_struct``).
"""
from drgn import Object, container_of
from drgn import container_of
from drgn.helpers import escape_string
from drgn.helpers.linux.device import MAJOR, MINOR, MKDEV
from drgn.helpers.linux.list import list_for_each_entry

View File

@ -11,7 +11,7 @@ Linux virtual filesystem (VFS) layer, including mounts, dentries, and inodes.
import os
from drgn import Object, Program, container_of
from drgn import Program, container_of
from drgn.helpers import escape_string
from drgn.helpers.linux.list import hlist_for_each_entry, list_for_each_entry

View File

@ -9,7 +9,7 @@ The ``drgn.helpers.linux.rbtree`` module provides helpers for working with
red-black trees from :linux:`include/linux/rbtree.h`.
"""
from drgn import Object, container_of
from drgn import Object, NULL, container_of
__all__ = [

View File

@ -17,7 +17,6 @@ def parse_rst(input_file):
SimpleNamespace(name='', state='CONTENT', lines=None,
directive_indentation='', content_indentation='')
]
state = None
for line in input_file:
line = line.rstrip()
indentation = re.match(r'\s*', line).group()

View File

@ -75,7 +75,7 @@ class my_sdist(sdist):
# pypa/setuptools#436 or the autotools output being out of date),
# require the repository to be clean (no unknown or ignored files).
# This check can be disabled with --force.
if not self.force and subprocess.check_output(['git', 'clean', '-dnx']):
if (not self.force and subprocess.check_output(['git', 'clean', '-dnx'])):
raise DistutilsSetupError('repository has untracked or ignored files; '
'please run git clean -dfx or use --force')
super().run()

View File

@ -117,9 +117,9 @@ def _compile_debug_line(buf, cu_die, little_endian):
offset = len(buf)
byteorder = 'little' if little_endian else 'big'
buf.extend(b'\0\0\0\0') # unit_length
buf.extend(b'\0\0\0\0') # unit_length
buf.extend((4).to_bytes(2, byteorder)) # version
buf.extend(b'\0\0\0\0') # header_length
buf.extend(b'\0\0\0\0') # header_length
buf.append(1) # minimum_instruction_length
buf.append(1) # maximum_operations_per_instruction
buf.append(1) # default_is_stmt

View File

@ -8,7 +8,7 @@ import drgn
from drgn.internal.mock import MockType
from tests import _drgn_pydll, _drgn_cdll
from tests.libelf import _Elf, Elf
from tests.libdw import _Dwarf_Die, Die, Dwarf
from tests.libdw import _Dwarf_Die, Die
class _drgn_error(ctypes.Structure):
@ -382,7 +382,6 @@ def _partial_object_wrap(pobj, parent):
little_endian=pobj.little_endian)
class _drgn_object_index(ctypes.Structure):
pass

View File

@ -1,4 +1,3 @@
import copy
import unittest
from drgn import (
@ -6,9 +5,8 @@ from drgn import (
FileFormatError,
function_type,
int_type,
Type,
)
from tests.dwarf import DW_AT, DW_ATE, DW_FORM, DW_TAG
from tests.dwarf import DW_AT, DW_FORM, DW_TAG
from tests.dwarfwriter import compile_dwarf, DwarfDie, DwarfAttrib
from tests.libdrgn import (
DwarfIndex,
@ -19,7 +17,6 @@ from tests.libdrgn import (
)
import tests.libelf as libelf
from tests.test_dwarf_type_index import int_die, unsigned_int_die
from tests.test_type_index import color_type
class TestDwarfObjectIndex(unittest.TestCase):

View File

@ -3,7 +3,6 @@ import unittest
from drgn import (
array_type,
bool_type,
complex_type,
enum_type,
FileFormatError,
@ -202,6 +201,7 @@ base_type_dies += (DwarfDie(
),
),)
class TestDwarfTypeIndex(unittest.TestCase):
@staticmethod
def type_index_and_elf(dies, little_endian=True, bits=64):
@ -982,7 +982,7 @@ class TestDwarfTypeIndex(unittest.TestCase):
self.assertFromDwarf(
dies, typedef_type('INT', int_type('int', 4, True)))
name = dies[0].attribs.pop(0)
dies[0].attribs.pop(0)
self.assertRaisesRegex(FileFormatError,
'DW_TAG_typedef has missing or invalid DW_AT_name',
self.type_from_dwarf, dies)
@ -998,7 +998,7 @@ class TestDwarfTypeIndex(unittest.TestCase):
]
self.assertFromDwarf(dies, typedef_type('VOID', void_type()))
name = dies[0].attribs.pop(0)
dies[0].attribs.pop(0)
self.assertRaisesRegex(FileFormatError,
'DW_TAG_typedef has missing or invalid DW_AT_name',
self.type_from_dwarf, dies)

View File

@ -55,11 +55,11 @@ class ObjectTestCase(unittest.TestCase):
exc_a = exc_b = False
try:
value_a = a.value_()
except Exception as e:
except Exception:
exc_a = True
try:
value_b = b.value_()
except Exception as e:
except Exception:
exc_b = True
if exc_a and not exc_b:
raise self.failureException(msg or f'exception raised while reading {a!r}')
@ -594,6 +594,7 @@ class TestInvalidBitField(ObjectTestCase):
'bit field size is larger than type size',
Object, self.prog, 'unsigned int', address=0,
bit_field_size=64)
def test_float(self):
self.assertRaisesRegex(ValueError, 'bit field must be integer',
Object, self.prog, 'float', value=0,
@ -1532,7 +1533,6 @@ class TestCPretty(ObjectTestCase):
self.assertEqual(str(Object(self.prog, 'int [0]', address=0)),
'(int [0]){}')
def test_array_zeroes(self):
segment = bytearray(16)
prog = mock_program(8, 'little', segments=[
@ -1773,7 +1773,7 @@ class TestGenericOperators(ObjectTestCase):
Object(prog, 'int *', value=0xffff0000),
]
for obj in strings:
self.assertEqual(obj.string_(), b'hello')
self.assertEqual(obj.string_(), b'hello')
self.assertRaisesRegex(TypeError, 'must be an array or pointer',
Object(prog, 'int', value=1).string_)

View File

@ -48,7 +48,6 @@ class TestSerialize(unittest.TestCase):
for bit_size in range(1, 65):
value = VALUE & ((1 << bit_size) - 1)
for bit_offset in range(8):
size = (bit_offset + bit_size + 7) // 8
for little_endian in [True, False]:
expected0, expected1 = py_serialize_bits(value, bit_offset,
bit_size,

View File

@ -1,6 +1,5 @@
import unittest
import drgn
from drgn import (
array_type,
bool_type,
@ -99,7 +98,6 @@ class TestType(unittest.TestCase):
complex_type, 'double _Complex', 16,
float_type('double', 8, Qualifiers.CONST))
def test_struct(self):
t = struct_type('point', 8, (
(int_type('int', 4, True), 'x', 0),