Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions stdlib/@tests/test_cases/check_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import csv
import sys

csv.writer(open("test.csv", "w"), quoting=csv.QUOTE_ALL)
csv.writer(open("test.csv", "w"), quoting=csv.QUOTE_MINIMAL)
csv.writer(open("test.csv", "w"), quoting=csv.QUOTE_NONE)
csv.writer(open("test.csv", "w"), quoting=csv.QUOTE_NONNUMERIC)

if sys.version_info >= (3, 12):
csv.writer(open("test.csv", "w"), quoting=csv.QUOTE_STRINGS)
csv.writer(open("test.csv", "w"), quoting=csv.QUOTE_NOTNULL)


csv.reader(open("test.csv", "r"), quoting=20) # type: ignore
9 changes: 5 additions & 4 deletions stdlib/_csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import csv
import sys
from _typeshed import SupportsWrite
from collections.abc import Iterable
from typing import Any, Final, type_check_only
from typing import Any, Final, Literal, type_check_only
from typing_extensions import Self, TypeAlias

__version__: Final[str]
Expand All @@ -15,9 +15,10 @@ if sys.version_info >= (3, 12):
QUOTE_STRINGS: Final = 4
QUOTE_NOTNULL: Final = 5

# Ideally this would be `QUOTE_ALL | QUOTE_MINIMAL | QUOTE_NONE | QUOTE_NONNUMERIC`
# However, using literals in situations like these can cause false-positives (see #7258)
_QuotingType: TypeAlias = int
if sys.version_info >= (3, 12):
_QuotingType: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
else:
_QuotingType: TypeAlias = Literal[0, 1, 2, 3]

class Error(Exception): ...

Expand Down