Missing python interface file

Aperta
#218 0 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Review the documented yara-python API and the proposed .pyi interface, then check how the compiled package is laid out in this repository. Compare the result with mypy stubgen output and verify the stubs support VSCode type hinting and code completion. Done means a correct .pyi file is included in the package with the public functions and classes represented.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The compiled yara-python is missing a python interface file (.pyi).

Without such an interface definition, support in IDEs is quite limited (no type hinting, no code completion).

I've created a small interface file based on the documentation, which is definitely not 100% correct, but enough to enable code completion and type hinting in VSCode:

from typing import IO, Callable, Dict, List, Tuple, Union

class Match:

    rule: str
    namespace: str
    tags: List[str]
    meta: Dict[str, str]
    strings: List[Tuple[int, str, str]]

class Rules:
    def match(
        self,
        filepath: str = "",
        pid: int = 0,
        data: Union[str, bytes] = "",
        externals: dict = {},
        callback: Callable = lambda x: x,
        fast: bool = False,
        timeout: int = -1,
        modules_data: dict = {},
        modules_callback: Callable = lambda x: x,
        warnings_callback: Callable = lambda x: x,
        which_callbacks: int = 0,
        console_callback: Callable = lambda x: x,
    ) -> List[Match]:
        pass
    def save(self, filepath: str = "", file: IO = None) -> None:
        pass

def compile(
    filepath: str = "",
    source: str = "",
    file: IO = None,
    filepaths: dict = {},
    sources: dict = {},
    externals: dict = {},
    includes: bool = True,
    error_on_warning: bool = False,
) -> Rules:
    pass

def load(filepath: str = "", file: IO = None) -> Rules:
    pass

def set_config(
    stack_size: int = -1, max_strings_per_rule: int = -1, max_match_data: int = -1
) -> None:
    pass

Adding a correct .pyi file to this repo, which can also be autogenerated using mypys stubgen (https://mypy.readthedocs.io/en/stable/stubgen.html), would obviously be the preferred solution.
I already tried autogeneration with stubgen, which did not work that good (function parameters and type hints were missing).

Lingua principale
C
Stelle
754
Fork
190
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di VirusTotal/yara-python

Tutte le issue di VirusTotal/yara-python

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.