Skip to content

TYP: some types for pandas/io/formats/csvs.py #30000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions pandas/io/formats/csvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import csv as csvlib
from io import StringIO
import os
from typing import Any, Dict, List
import warnings
from zipfile import ZipFile

Expand Down Expand Up @@ -187,7 +188,7 @@ def save(self):
close = True

try:
writer_kwargs = dict(
kwargs: Dict[str, Any] = dict(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the rename? ive recently been finding more-specific names for kwargs useful when tracking down less-specific usages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no reason other than for consistency of variable names. will revert tomorrow.

lineterminator=self.line_terminator,
delimiter=self.sep,
quoting=self.quoting,
Expand All @@ -196,10 +197,9 @@ def save(self):
quotechar=self.quotechar,
)
if self.encoding == "ascii":
self.writer = csvlib.writer(f, **writer_kwargs)
self.writer = csvlib.writer(f, **kwargs)
else:
writer_kwargs["encoding"] = self.encoding
self.writer = UnicodeWriter(f, **writer_kwargs)
self.writer = UnicodeWriter(f, encoding=self.encoding, **kwargs)

self._save()

Expand Down Expand Up @@ -233,7 +233,7 @@ def _save_header(self):
cols = self.cols
has_mi_columns = self.has_mi_columns
header = self.header
encoded_labels = []
encoded_labels: List[str] = []

has_aliases = isinstance(header, (tuple, list, np.ndarray, ABCIndexClass))
if not (has_aliases or self.header):
Expand Down