Skip to content

Commit 2a46e10

Browse files
committed
Fix pyright
1 parent 320e649 commit 2a46e10

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/stdlib/csv/_csv.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def sniff(
283283
try:
284284
# Attempt to parse first few lines with this delimiter
285285
# This is a simplified sniffer. A real one is much more complex.
286-
potential_dialect_params = {"delimiter": delim_char}
286+
potential_dialect_params: Dict[str, Any] = {"delimiter": delim_char}
287287

288288
# Try to guess quotechar and quoting style
289289
# Count quotechar occurrences to infer
@@ -312,16 +312,10 @@ def sniff(
312312
):
313313
potential_dialect_params["doublequote"] = True
314314
else:
315-
potential_dialect_params["doublequote"] = (
316-
False # Could be escapechar or just not used
317-
)
315+
potential_dialect_params["doublequote"] = False
318316
else: # No clear quotechar or odd number, assume no quoting or minimal that's not obvious
319-
potential_dialect_params["quotechar"] = (
320-
'"' # Default, or could be None
321-
)
322-
potential_dialect_params["quoting"] = (
323-
QUOTE_MINIMAL # Or QUOTE_NONE if no quotes seen
324-
)
317+
potential_dialect_params["quotechar"] = '"'
318+
potential_dialect_params["quoting"] = QUOTE_MINIMAL
325319

326320
# This is where a mini-parser run would be beneficial
327321
# For now, use a heuristic: consistent number of fields
@@ -559,7 +553,8 @@ def reader(
559553
elif char == quotechar:
560554
if doublequote:
561555
if idx + 1 < len_row and row_str[idx + 1] == quotechar:
562-
current_field += quotechar
556+
if quotechar is not None:
557+
current_field += quotechar
563558
idx += 1
564559
else:
565560
state = AFTER_QUOTED_FIELD

tests/test_csv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ def test_dialect_properties_validation(self):
579579
):
580580
csv.Dialect(delimiter="long")
581581
with pytest.raises(TypeError, match="doublequote must be a boolean"):
582-
csv.Dialect(doublequote="true") # Invalid type - should be boolean
582+
csv.Dialect(doublequote="true") # type: ignore # Invalid type - should be boolean
583583
# ... other validation checks in Dialect.__init__ can be tested similarly
584584

585585
def test_predefined_dialects_exist(self):

0 commit comments

Comments
 (0)