Fix some misc type errors (#1509)

* Fix some misc type errors

* Add missing return type hints
pull/1510/head
Gulshan Singh 3 years ago committed by GitHub
parent 3a45e3c669
commit 7e519bb660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -233,7 +233,8 @@ def fix_int(*a, **kw):
def fix_int_reraise(*a, **kw):
return fix(*a, reraise=True, **kw)
# Type error likely due to https://github.com/python/mypy/issues/6799
return fix(*a, reraise=True, **kw) # type: ignore[misc]
def OnlyWithFile(function):
@ -461,9 +462,6 @@ class _ArgparsedCommand(Command):
parser,
function,
command_name=None,
is_alias=False,
aliases=[],
category=CommandCategory.MISC,
*a,
**kw,
) -> None:
@ -480,12 +478,10 @@ class _ArgparsedCommand(Command):
# Note: function.__doc__ is used in the `pwndbg [filter]` command display
function.__doc__ = self.parser.description.strip()
super(_ArgparsedCommand, self).__init__(
# Type error likely due to https://github.com/python/mypy/issues/6799
super(_ArgparsedCommand, self).__init__( # type: ignore[misc]
function,
command_name=command_name,
is_alias=is_alias,
aliases=aliases,
category=category,
*a,
**kw,
)

@ -22,7 +22,7 @@ parser.add_argument(
@pwndbg.commands.ArgparsedCommand(parser, aliases=["pdisass", "u"], category=CommandCategory.DISASS)
@pwndbg.commands.OnlyWhenRunning
def nearpc(pc=None, lines=None, emulate=False):
def nearpc(pc=None, lines=None, emulate=False) -> None:
"""
Disassemble near a specified address.
"""
@ -44,7 +44,7 @@ parser.add_argument(
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.DISASS)
@pwndbg.commands.OnlyWhenRunning
def emulate(pc=None, lines=None, emulate_=True):
def emulate(pc=None, lines=None, emulate_=True) -> None:
"""
Like nearpc, but will emulate instructions from the current $PC forward.
"""

@ -96,17 +96,17 @@ def get_flags_list(flags: int):
class IndentContextManager:
def __init__(self):
def __init__(self) -> None:
self.indent = 0
def __enter__(self):
def __enter__(self) -> None:
self.indent += 1
def __exit__(self, exc_type, exc_value, exc_tb):
def __exit__(self, exc_type, exc_value, exc_tb) -> None:
self.indent -= 1
assert self.indent >= 0
def print(self, *a, **kw):
def print(self, *a, **kw) -> None:
print(" " * self.indent, *a, **kw)
@ -129,7 +129,7 @@ def _rx(val: int) -> str:
def print_slab(
slab: gdb.Value, freelist: Union[Iterator[int], List[int]], indent, verbose, is_partial
):
) -> None:
page_address = int(slab.address)
virt_address = pwndbg.gdblib.kernel.page_to_virt(page_address)
indent.print(f"- {C.green('Slab')} @ {_yx(virt_address)} [{_rx(page_address)}]:")
@ -157,7 +157,7 @@ def print_slab(
indent.print("-", _yx(int(entry)))
def print_cpu_cache(cpu_cache, offset, random, cpu_partial, indent, verbose):
def print_cpu_cache(cpu_cache, offset, random, cpu_partial, indent, verbose) -> None:
address = int(cpu_cache)
indent.print(f"{C.green('Per-CPU Data')} @ {_yx(address)}:")
with indent:
@ -195,7 +195,7 @@ def print_cpu_cache(cpu_cache, offset, random, cpu_partial, indent, verbose):
indent.print("Partial Slabs: (none)")
def slab_info(name: str, verbose: bool):
def slab_info(name: str, verbose: bool) -> None:
cache = pwndbg.gdblib.kernel.slab.get_cache(name)
if cache is None:
@ -231,7 +231,7 @@ def slab_info(name: str, verbose: bool):
# TODO: print_node_cache
def slab_list(filter_):
def slab_list(filter_) -> None:
results = []
for cache in pwndbg.gdblib.kernel.slab.caches():
name = cache["name"].string()

@ -94,7 +94,7 @@ class module(ModuleType):
return item
def __contains__(self, reg):
def __contains__(self, reg) -> bool:
regs = set(reg_sets[pwndbg.gdblib.arch.current]) | {"pc", "sp"}
return reg in regs

@ -17,7 +17,6 @@ pretty = true
show_error_codes = true
incremental = false
disable_error_code = [
"misc",
# Lots of dynamic attribute access
"attr-defined",
# https://github.com/python/mypy/issues/6232

Loading…
Cancel
Save