Skip to content

Commit 8063c2e

Browse files
authored
Improve imp._FileLike.__exit__
The signature of this method currently doesn't work quite as intended: see PyCQA/flake8-pyi#199 (comment) Classes will [still be accepted](https://mypy-play.net/?mypy=latest&python=3.10&gist=77efe095d01edeb1a4614166f0c9cf68) as conforming to this protocol if they have more permissive signatures such as `def __exit__(self, *args: object) -> None: ...`
1 parent ec27c00 commit 8063c2e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stdlib/imp.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import types
22
from _typeshed import StrPath
33
from os import PathLike
4+
from types import TracebackType
45
from typing import IO, Any, Protocol
56

67
from _imp import (
@@ -45,7 +46,7 @@ class _FileLike(Protocol):
4546
def read(self) -> str | bytes: ...
4647
def close(self) -> Any: ...
4748
def __enter__(self) -> Any: ...
48-
def __exit__(self, *args: Any) -> Any: ...
49+
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> Any: ...
4950

5051
# PathLike doesn't work for the pathname argument here
5152
def load_source(name: str, pathname: str, file: _FileLike | None = ...) -> types.ModuleType: ...

0 commit comments

Comments
 (0)