Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ci:
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -36,7 +36,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.2"
rev: "v0.13.2"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -45,7 +45,7 @@ repos:

# Checking static types
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.10.0"
rev: "v1.18.2"
hooks:
- id: mypy
exclude: ^(tests)|^(examples)
Expand Down
2 changes: 1 addition & 1 deletion examples/clone-matplotlib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"from pythonbpf import bpf, map, section, bpfglobal, BPF\n",
"from pythonbpf.helper import pid\n",
"from pythonbpf.maps import HashMap\n",
"from pylibbpf import *\n",
"from pylibbpf import BpfMap\n",
"from ctypes import c_void_p, c_int64, c_uint64, c_int32\n",
"import matplotlib.pyplot as plt"
]
Expand Down
6 changes: 2 additions & 4 deletions pythonbpf/functions_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ def handle_assign(
local_sym_tab[var_name].var,
)
logger.info(
f"Assigned {call_type} constant "
f"{rval.args[0].value} to {var_name}"
f"Assigned {call_type} constant {rval.args[0].value} to {var_name}"
)
elif HelperHandlerRegistry.has_handler(call_type):
# var = builder.alloca(ir.IntType(64), name=var_name)
Expand Down Expand Up @@ -485,8 +484,7 @@ def allocate_mem(
var = builder.alloca(ir_type, name=var_name)
has_metadata = True
logger.info(
f"Pre-allocated variable {var_name} "
f"for struct {call_type}"
f"Pre-allocated variable {var_name} for struct {call_type}"
)
elif isinstance(rval.func, ast.Attribute):
ir_type = ir.PointerType(ir.IntType(64))
Expand Down
9 changes: 4 additions & 5 deletions pythonbpf/helper/bpf_helper_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def bpf_map_lookup_elem_emitter(
"""
if not call.args or len(call.args) != 1:
raise ValueError(
"Map lookup expects exactly one argument (key), got " f"{len(call.args)}"
f"Map lookup expects exactly one argument (key), got {len(call.args)}"
)
key_ptr = get_or_create_ptr_from_arg(call.args[0], builder, local_sym_tab)
map_void_ptr = builder.bitcast(map_ptr, ir.PointerType())
Expand Down Expand Up @@ -145,8 +145,7 @@ def bpf_map_update_elem_emitter(
"""
if not call.args or len(call.args) < 2 or len(call.args) > 3:
raise ValueError(
"Map update expects 2 or 3 args (key, value, flags), "
f"got {len(call.args)}"
f"Map update expects 2 or 3 args (key, value, flags), got {len(call.args)}"
)

key_arg = call.args[0]
Expand Down Expand Up @@ -196,7 +195,7 @@ def bpf_map_delete_elem_emitter(
"""
if not call.args or len(call.args) != 1:
raise ValueError(
"Map delete expects exactly one argument (key), got " f"{len(call.args)}"
f"Map delete expects exactly one argument (key), got {len(call.args)}"
)
key_ptr = get_or_create_ptr_from_arg(call.args[0], builder, local_sym_tab)
map_void_ptr = builder.bitcast(map_ptr, ir.PointerType())
Expand Down Expand Up @@ -255,7 +254,7 @@ def bpf_perf_event_output_handler(
):
if len(call.args) != 1:
raise ValueError(
"Perf event output expects exactly one argument, " f"got {len(call.args)}"
f"Perf event output expects exactly one argument, got {len(call.args)}"
)
data_arg = call.args[0]
ctx_ptr = func.args[0] # First argument to the function is ctx
Expand Down
2 changes: 1 addition & 1 deletion pythonbpf/helper/helper_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def _prepare_expr_args(expr, func, module, builder, local_sym_tab, struct_sym_ta
val = builder.sext(val, ir.IntType(64))
else:
logger.warning(
"Only int and ptr supported in bpf_printk args. " "Others default to 0."
"Only int and ptr supported in bpf_printk args. Others default to 0."
)
val = ir.Constant(ir.IntType(64), 0)
return val
Expand Down
4 changes: 1 addition & 3 deletions pythonbpf/maps/maps_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,7 @@ def process_bpf_map(func_node, module):
if handler:
return handler(map_name, rval, module)
else:
logger.warning(
f"Unknown map type " f"{rval.func.id}, defaulting to HashMap"
)
logger.warning(f"Unknown map type {rval.func.id}, defaulting to HashMap")
return process_hash_map(map_name, rval, module)
else:
raise ValueError("Function under @map must return a map")