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
18 changes: 9 additions & 9 deletions pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@
PythonFuncType = Callable[[Any], Any]

# filenames and file-like-objects
AnyStr_cov = TypeVar("AnyStr_cov", str, bytes, covariant=True)
AnyStr_con = TypeVar("AnyStr_con", str, bytes, contravariant=True)
AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True)
AnyStr_contra = TypeVar("AnyStr_contra", str, bytes, contravariant=True)


class BaseBuffer(Protocol):
Expand All @@ -212,14 +212,14 @@ def tell(self) -> int:
...


class ReadBuffer(BaseBuffer, Protocol[AnyStr_cov]):
def read(self, __n: int = ...) -> AnyStr_cov:
class ReadBuffer(BaseBuffer, Protocol[AnyStr_co]):
def read(self, __n: int = ...) -> AnyStr_co:
# for BytesIOWrapper, gzip.GzipFile, bz2.BZ2File
...


class WriteBuffer(BaseBuffer, Protocol[AnyStr_con]):
def write(self, __b: AnyStr_con) -> Any:
class WriteBuffer(BaseBuffer, Protocol[AnyStr_contra]):
def write(self, __b: AnyStr_contra) -> Any:
# for gzip.GzipFile, bz2.BZ2File
...

Expand All @@ -238,16 +238,16 @@ def truncate(self, size: int | None = ...) -> int:
...


class ReadCsvBuffer(ReadBuffer[AnyStr_cov], Protocol):
def __iter__(self) -> Iterator[AnyStr_cov]:
class ReadCsvBuffer(ReadBuffer[AnyStr_co], Protocol):
def __iter__(self) -> Iterator[AnyStr_co]:
# for engine=python
...

def fileno(self) -> int:
# for _MMapWrapper
...

def readline(self) -> AnyStr_cov:
def readline(self) -> AnyStr_co:
# for engine=python
...

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ disable = [
"missing-module-docstring",
"singleton-comparison",
"too-many-lines",
"typevar-name-incorrect-variance",
"ungrouped-imports",
"unidiomatic-typecheck",
"unnecessary-dunder-call",
Expand Down