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
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ repos:
args: [--show-error-codes, --ignore-missing-imports]
additional_dependencies:
[types-setuptools, types-requests, types-python-dateutil]
# This file is overridden by a type stub
exclude: "specfile/context_management.py"
- repo: https://github.com/teemtee/tmt.git
rev: 1.41.0
hooks:
Expand Down
25 changes: 25 additions & 0 deletions specfile/context_management.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

import contextlib
from collections.abc import Iterator
from typing import Callable, Generator, ParamSpec, TypeVar

_T_co = TypeVar("_T_co", covariant=True)
_P = ParamSpec("_P")

@contextlib.contextmanager
def capture_stderr() -> Generator[list[bytes], None, None]: ...

class GeneratorContextManager(contextlib._GeneratorContextManager[_T_co]):
def __init__(self, function: Callable[..., _T_co]) -> None: ...
def __del__(self) -> None: ...
@property
def content(self) -> _T_co: ...

# Instead of the original descriptor class, tell the type checker to treat
# ContextManager as a simple decorator function which is something that it
# understands.
def ContextManager(
func: Callable[_P, Iterator[_T_co]],
) -> Callable[_P, GeneratorContextManager[_T_co]]: ...
Loading