Skip to content

Commit f1e1ac8

Browse files
committed
TYP: chunksize, but ignored assignment check
For some reason mypy would not recognize that chunksize turns from Optional[int] to int inside the setter. Even setting an intentional assertion ``assert chunksize is not None`` does not help.
1 parent a49dd63 commit f1e1ac8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/io/formats/csvs.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __init__(
112112
self.line_terminator = line_terminator or os.linesep
113113
self.date_format = date_format
114114
self.cols = cols
115-
self.chunksize = chunksize
115+
self.chunksize = chunksize # type: ignore[assignment]
116116

117117
@property
118118
def index_label(self) -> IndexLabel:
@@ -197,13 +197,14 @@ def _number_format(self) -> dict:
197197
)
198198

199199
@property
200-
def chunksize(self):
200+
def chunksize(self) -> int:
201201
return self._chunksize
202202

203203
@chunksize.setter
204-
def chunksize(self, chunksize):
204+
def chunksize(self, chunksize: Optional[int]) -> None:
205205
if chunksize is None:
206206
chunksize = (100000 // (len(self.cols) or 1)) or 1
207+
assert chunksize is not None
207208
self._chunksize = int(chunksize)
208209

209210
@property

0 commit comments

Comments
 (0)