Skip to content

Commit

Permalink
Make linters happy
Browse files Browse the repository at this point in the history
  • Loading branch information
rdunklau committed Apr 14, 2023
1 parent 832b73f commit 2625d14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
11 changes: 1 addition & 10 deletions src/pgtracer/ebpf/dwarf.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class Struct:
fields_defs: Dict[str, StructMemberDefinition]
metadata: ProcessMetadata
die: DIE
buffer_type: Type
buffer_type: Type[ct._CData]
_fully_loaded: bool = False
size: int

Expand Down Expand Up @@ -634,15 +634,6 @@ def as_dict(self, include_all: bool = False) -> Dict[str, Any]:
value.as_dict(include_all=True)
return values

@classmethod
def size(cls) -> int:
"""
Returns the sizeof() this struct as stored in the DWARF information.
"""
size = cls.die.attributes["DW_AT_byte_size"].value
assert isinstance(size, int)
return size

@classmethod
def pointer_type(cls) -> Type[DWARFPointer]:
"""
Expand Down
5 changes: 2 additions & 3 deletions src/pgtracer/model/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import ctypes as ct
from typing import TYPE_CHECKING, Dict, Optional

from ..ebpf.collector.c_defs import plan_data, planstate_data
from ..ebpf.dwarf import ProcessMetadata, Struct
from ..utils import timespec_to_float

if TYPE_CHECKING:
from enum import IntEnum

from ..ebpf.collector.c_defs import plan_data, planstate_data
from ..ebpf.dwarf import ProcessMetadata, Struct


def explain_dict_to_str(parts: Dict[str, str]) -> str:
"""
Expand Down
6 changes: 4 additions & 2 deletions src/pgtracer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
import re
import subprocess
from datetime import timedelta
from typing import TYPE_CHECKING, BinaryIO, Optional
from typing import TYPE_CHECKING, BinaryIO, Optional, Union

from pypsutil import Process

from pgtracer.ebpf.dwarf import Struct

if TYPE_CHECKING:
from ctypes import _CData
else:
_CData = object


def timespec_to_timedelta(timespec: _CData) -> timedelta:
def timespec_to_timedelta(timespec: Union[_CData, Struct]) -> timedelta:
"""
Convert a timespec_t or instr_time struct to a timedelta.
"""
Expand Down

0 comments on commit 2625d14

Please sign in to comment.