-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If we're doing nominal typing, do it correctly.
- Loading branch information
Showing
6 changed files
with
38 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import annotations | ||
|
||
import abc | ||
import typing | ||
|
||
if typing.TYPE_CHECKING: | ||
from pathlib import Path | ||
from types import TracebackType | ||
|
||
|
||
class AbstractReader(abc.ABC): | ||
def __init__(self: AbstractReader, file_path: Path) -> None: | ||
self.file_path = file_path | ||
|
||
@abc.abstractmethod | ||
def __enter__(self: AbstractReader) -> AbstractReader: ... | ||
|
||
@typing.overload | ||
def __exit__(self, exc_type: None, exc_val: None, exc_tb: None) -> None: ... | ||
|
||
@typing.overload | ||
def __exit__( | ||
self, | ||
exc_type: type[BaseException], | ||
exc_val: BaseException, | ||
exc_tb: TracebackType, | ||
) -> None: ... | ||
|
||
@abc.abstractmethod | ||
def __exit__( | ||
self: AbstractReader, | ||
exc_type: type[BaseException] | None, | ||
exc_val: BaseException | None, | ||
exc_tb: TracebackType | None, | ||
) -> None: ... |