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
3 changes: 0 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ name: Format

on:
workflow_dispatch:
pull_request:
push:
branches:
- master

jobs:
pre-commit:
Expand Down
17 changes: 8 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ repos:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format
exclude: ^(docs)
exclude: ^(docs)|^(tests)|^(examples)

## Checking static types
#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: "v1.10.0"
# hooks:
# - id: mypy
# files: "setup.py"
# args: []
# additional_dependencies: [types-setuptools]
# Checking static types
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.10.0"
hooks:
- id: mypy
exclude: ^(tests)|^(examples)
additional_dependencies: [types-setuptools]

# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
Expand Down
2 changes: 1 addition & 1 deletion pythonbpf/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def compile() -> bool:
success = True
success = compile_to_ir(str(caller_file), str(ll_file)) and success

success = (
success = bool(
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit bool() wrapper is unnecessary. The subprocess.run() result in a boolean context already evaluates correctly for the and operation on line 142.

Copilot uses AI. Check for mistakes.

subprocess.run(
[
"llc",
Expand Down
10 changes: 5 additions & 5 deletions pythonbpf/functions_pass.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from llvmlite import ir
import ast

from typing import Any

from .bpf_helper_handler import helper_func_list, handle_helper_call
from .type_deducer import ctypes_to_ir
from .binary_ops import handle_binary_op
from .expr_pass import eval_expr, handle_expr

local_var_metadata = {}
local_var_metadata: dict[str | Any, Any] = {}
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type annotation dict[str | Any, Any] is overly permissive. Consider using a more specific type for the key (e.g., just str if all keys are strings) or define a TypedDict if the structure is predictable.

Suggested change
local_var_metadata: dict[str | Any, Any] = {}
local_var_metadata: dict[str, str] = {}

Copilot uses AI. Check for mistakes.



def get_probe_string(func_node):
Expand Down Expand Up @@ -656,9 +656,9 @@ def _expr_type(e):
except Exception:
return type(e).__name__

for node in ast.walk(func_node):
if isinstance(node, ast.Return):
t = _expr_type(node.value)
for walked_node in ast.walk(func_node):
if isinstance(walked_node, ast.Return):
t = _expr_type(walked_node.value)
if found_type is None:
found_type = t
elif found_type != t:
Expand Down
6 changes: 5 additions & 1 deletion pythonbpf/maps/maps_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from collections.abc import Callable
from typing import Any


class MapProcessorRegistry:
"""Registry for map processor functions"""

_processors = {}
_processors: dict[str, Callable[..., Any]] = {}

@classmethod
def register(cls, map_type_name):
Expand Down