Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

"Missing return statement" caused by context manager? #7577

Copy link
Copy link
Closed
@jonapich

Description

@jonapich
Issue body actions
""" Unit tests. """

from types import TracebackType
from typing import Optional, Type


class TestManager:
    def __enter__(self) -> None:
        ...

    def __exit__(self, exc_type: Optional[Type[BaseException]], 
                 exc_val: Optional[BaseException],
                 exc_tb: Optional[TracebackType]) -> bool:
        ...


def func() -> int:
    with TestManager():
        return 1

Mypy will complain about func(), saying it doesn't have a return statement.

tests/__init__.py:16:1: error: Missing return statement

Is this intended?

Note: I also tried class TestManager(ContextManager[None]): just to see if that would help mypy but it didn't change anything.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.