Skip to content

Commit 58c372b

Browse files
Merge pull request #12 from pythonbpf/ruff-errors
Ruff errors
2 parents 83e4094 + c27da22 commit 58c372b

File tree

10 files changed

+35
-15
lines changed

10 files changed

+35
-15
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ repos:
3535
- id: requirements-txt-fixer
3636
- id: trailing-whitespace
3737

38-
#- repo: https://github.com/astral-sh/ruff-pre-commit
39-
# rev: "v0.4.2"
40-
# hooks:
41-
# - id: ruff
42-
# args: ["--fix", "--show-fixes"]
43-
# - id: ruff-format
44-
# exclude: ^(docs)
38+
- repo: https://github.com/astral-sh/ruff-pre-commit
39+
rev: "v0.4.2"
40+
hooks:
41+
- id: ruff
42+
args: ["--fix", "--show-fixes"]
43+
- id: ruff-format
44+
exclude: ^(docs)
4545

4646
## Checking static types
4747
#- repo: https://github.com/pre-commit/mirrors-mypy

examples/clone_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pythonbpf import bpf, map, section, bpfglobal, BPF
44
from pythonbpf.helpers import pid
55
from pythonbpf.maps import HashMap
6-
from pylibbpf import *
6+
from pylibbpf import BpfMap
77
from ctypes import c_void_p, c_int64, c_uint64, c_int32
88
import matplotlib.pyplot as plt
99

examples/struct_and_perf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ def events() -> PerfEventArray:
2424
def hello(ctx: c_void_p) -> c_int32:
2525
dataobj = data_t()
2626
ts = ktime()
27-
process_id = pid()
2827
strobj = "hellohellohello"
2928
dataobj.pid = pid()
3029
dataobj.ts = ktime()
3130
# dataobj.comm = strobj
32-
print(f"clone called at {dataobj.ts} by pid {dataobj.pid}, comm {strobj}")
31+
print(
32+
f"clone called at {dataobj.ts} by pid {dataobj.pid}, comm {strobj} at time {ts}"
33+
)
3334
events.output(dataobj)
3435
return c_int32(0)
3536

pythonbpf/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
from .decorators import bpf, map, section, bpfglobal, struct
22
from .codegen import compile_to_ir, compile, BPF
3+
4+
__all__ = [
5+
"bpf",
6+
"map",
7+
"section",
8+
"bpfglobal",
9+
"struct",
10+
"compile_to_ir",
11+
"compile",
12+
"BPF",
13+
]

pythonbpf/debuginfo/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
from .dwarf_constants import *
2-
from .dtypes import *
1+
from .dwarf_constants import * # noqa: F403
2+
from .dtypes import * # noqa: F403
33
from .debug_info_generator import DebugInfoGenerator
4+
5+
__all__ = ["DebugInfoGenerator"]

pythonbpf/functions_pass.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def handle_assign(
189189
map_name = rval.func.value.func.id
190190
method_name = rval.func.attr
191191
if map_name in map_sym_tab:
192-
map_ptr = map_sym_tab[map_name]
192+
# map_ptr = map_sym_tab[map_name]
193193
if method_name in helper_func_list:
194194
val = handle_helper_call(
195195
rval,
@@ -289,7 +289,7 @@ def handle_if(
289289
):
290290
"""Handle if statements in the function body."""
291291
print("Handling if statement")
292-
start = builder.block.parent
292+
# start = builder.block.parent
293293
then_block = func.append_basic_block(name="if.then")
294294
merge_block = func.append_basic_block(name="if.end")
295295
if stmt.orelse:
@@ -674,7 +674,7 @@ def assign_string_to_array(builder, target_array_ptr, source_string_ptr, array_l
674674
Copy a string (i8*) to a fixed-size array ([N x i8]*)
675675
"""
676676
# Create a loop to copy characters one by one
677-
entry_block = builder.block
677+
# entry_block = builder.block
678678
copy_block = builder.append_basic_block("copy_char")
679679
end_block = builder.append_basic_block("copy_end")
680680

pythonbpf/maps/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
from .maps import HashMap, PerfEventArray
22
from .maps_pass import maps_proc
3+
4+
__all__ = ["HashMap", "PerfEventArray", "maps_proc"]

pythonbpf/structs/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .structs_pass import structs_proc
2+
3+
__all__ = ["structs_proc"]

tests/failing_tests/binops.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@section("sometag1")
77
def sometag(ctx: c_void_p) -> c_int64:
88
a = 1 + 2 + 1
9+
print(f"{a}")
910
return c_int64(0)
1011

1112

tests/failing_tests/license.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
@section("sometag1")
88
def sometag(ctx: c_void_p) -> c_int64:
99
a = 1 + 2
10+
print(f"{a}")
1011
return c_int64(0)
1112

1213

0 commit comments

Comments
 (0)