Skip to content

typing #262

@nafe93

Description

@nafe93

Hello,

I actively use rawpy in Python projects together with VS Code + Pylance and static type checkers (Mypy/Pyright).
Currently, rawpy does not ship with .pyi stub files or inlined type hints, so IDEs cannot provide autocompletion for attributes and methods like raw_image_visible, sizes, white_level, etc. Without type hints, the developer experience is significantly reduced.

It would be very helpful if the package could include official type stubs for the main API, especially for the RawPy class and its related structures (sizes, imread, etc.).

Example of what could be in rawpy/init.pyi (minimal version):

from typing import Optional, Tuple
import numpy as np

class Sizes:
raw_height: int
raw_width: int
top_margin: int
bottom_margin: int
left_margin: int
right_margin: int

class RawPy:
raw_image: np.ndarray
raw_image_visible: Optional[np.ndarray]
sizes: Sizes
white_level: int
def postprocess(
self,
use_camera_wb: bool = ...,
no_auto_bright: bool = ...,
gamma: Tuple[float, float] = ...,
output_bps: int = ...,
demosaic_algorithm: int = ...,
) -> np.ndarray: ...
def enter(self) -> "RawPy": ...
def exit(self, exc_type, exc, tb) -> None: ...

def imread(pathOrFile) -> RawPy: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions