mypy: fix typing issues + CI + lint.sh (#3141)

* fix mypy errors
pull/3143/head
patryk4815 6 months ago committed by GitHub
parent 9200ae4b87
commit 567ac6048c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -50,8 +50,8 @@ jobs:
level: error level: error
# Change the current directory to run mypy command. # Change the current directory to run mypy command.
# mypy command reads setup.cfg or other settings file in this path. # mypy command reads setup.cfg or other settings file in this path.
execute_command: uv run --group lint --group dev mypy execute_command: uv run --group dev --group lint --group tests --extra gdb --extra lldb mypy
install_types: false install_types: false
target: pwndbg target: pwndbg pwndbginit tests/host
filter_mode: nofilter filter_mode: nofilter
fail_on_error: true fail_on_error: true

@ -71,5 +71,5 @@ $UV_RUN_LINT vermin -vvv --no-tips -t=3.10- --eval-annotations --violations ${LI
# mypy is run in a separate step on GitHub Actions # mypy is run in a separate step on GitHub Actions
if [[ -z "$GITHUB_ACTIONS" ]]; then if [[ -z "$GITHUB_ACTIONS" ]]; then
$UV_RUN_LINT mypy pwndbg pwndbginit tests/host $UV_RUN_MYPY mypy pwndbg pwndbginit tests/host
fi fi

@ -34,7 +34,7 @@ def run_uv_install(
else: else:
# We don't want to quietly uninstall dependencies by just specifying # We don't want to quietly uninstall dependencies by just specifying
# `--extra gdb` so we will be conservative and pull all extras in. # `--extra gdb` so we will be conservative and pull all extras in.
command: List[str] = [str(binary_path), "sync", "--all-extras"] command = [str(binary_path), "sync", "--all-extras"]
if dev: if dev:
command.append("--all-groups") command.append("--all-groups")
logging.debug(f"Updating deps with command: {' '.join(command)}") logging.debug(f"Updating deps with command: {' '.join(command)}")

@ -21,10 +21,14 @@ def get_gdb_version(path: str) -> Tuple[str, str]:
capture_output=True, capture_output=True,
text=True, text=True,
) )
return tuple(result.stdout.strip().split(" ", 2))
arr = result.stdout.strip().split(" ", 1)
if len(arr) != 2:
return "", ""
return arr[0], arr[1]
def get_venv_bin_path():
def get_venv_bin_path() -> str:
bin_dir = "Scripts" if os.name == "nt" else "bin" bin_dir = "Scripts" if os.name == "nt" else "bin"
return os.path.join(sys.prefix, bin_dir) return os.path.join(sys.prefix, bin_dir)
@ -54,7 +58,7 @@ def main():
sys.argv = gdb_argv sys.argv = gdb_argv
try: try:
from gdb_for_pwndbg.gdb import main from gdb_for_pwndbg.gdb import main # type: ignore[import-untyped]
main() main()
return return

@ -18,11 +18,13 @@ if [[ "$PWNDBG_NO_UV" == "1" ]]; then
UV_RUN_TEST="" UV_RUN_TEST=""
UV_RUN_LINT="" UV_RUN_LINT=""
UV_RUN_DOCS="" UV_RUN_DOCS=""
UV_RUN_MYPY=""
else else
# We are going to use uv. # We are going to use uv.
UV="${PWNDBG_VENV_PATH}/bin/uv" UV="${PWNDBG_VENV_PATH}/bin/uv"
UV_RUN="${UV} run" UV_RUN="${UV} run"
UV_RUN_TEST="${UV_RUN} --group dev --group tests --all-extras" UV_RUN_TEST="${UV_RUN} --group dev --group tests --all-extras"
UV_RUN_LINT="${UV_RUN} --group dev --group lint" UV_RUN_LINT="${UV_RUN} --group lint"
UV_RUN_DOCS="${UV_RUN} --group docs --extra gdb --extra lldb" UV_RUN_DOCS="${UV_RUN} --group docs --extra gdb --extra lldb"
UV_RUN_MYPY="${UV_RUN} --group dev --group lint --group tests --extra gdb --extra lldb"
fi fi

Loading…
Cancel
Save