-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
gh-137986: Fix and improve the csv functions docstrings #137987
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
gh-137986: Fix and improve the csv functions docstrings #137987
Conversation
The csv.register_dialect() docstring no longer imply that it returns a dialect. All functions have now signatures.
The diff of the pydoc output: @@ -149,58 +149,45 @@
field_size_limit(new_limit=<unrepresentable>)
Sets an upper limit on parsed fields.
- csv.field_size_limit([limit])
-
Returns old limit. If limit is not given, no new limit is set and
the old limit is returned
get_dialect(name)
Return the dialect instance associated with name.
- dialect = csv.get_dialect(name)
-
list_dialects()
Return a list of all known dialect names.
- names = csv.list_dialects()
-
- reader(...)
- csv_reader = reader(iterable [, dialect='excel']
- [optional keyword args])
- for row in csv_reader:
- process(row)
+ reader(iterable, /, dialect='excel', **fmtparams)
+ Return a reader object that will process lines from the given iterable.
The "iterable" argument can be any object that returns a line
of input for each iteration, such as a file object or a list. The
- optional "dialect" parameter is discussed below. The function
+ optional "dialect" argument defines a CSV dialect. The function
also accepts optional keyword arguments which override settings
provided by the dialect.
The returned object is an iterator. Each iteration returns a row
of the CSV file (which can span multiple input lines).
- register_dialect(...)
- Create a mapping from a string name to a dialect class.
- dialect = csv.register_dialect(name[, dialect[, **fmtparams]])
+ register_dialect(name, /, dialect='excel', **fmtparams)
+ Create a mapping from a string name to a CVS dialect.
+
+ The optional "dialect" argument specifies the base dialect instance
+ or the name of the registered dialect. The function also accepts
+ optional keyword arguments which override settings provided by the
+ dialect.
unregister_dialect(name)
Delete the name/dialect mapping associated with a string name.
- csv.unregister_dialect(name)
-
- writer(...)
- csv_writer = csv.writer(fileobj [, dialect='excel']
- [optional keyword args])
- for row in sequence:
- csv_writer.writerow(row)
-
- [or]
-
- csv_writer = csv.writer(fileobj [, dialect='excel']
- [optional keyword args])
- csv_writer.writerows(rows)
+ writer(fileobj, /, dialect='excel', **fmtparams)
+ Return a writer object that will write user data on the given file object.
The "fileobj" argument can be any object that supports the file API.
+ The optional "dialect" argument defines a CSV dialect. The function
+ also accepts optional keyword arguments which override settings
+ provided by the dialect.
|
Oh so the other change is part of this PR. Good. |
Co-authored-by: maurycy <[email protected]>
Other changes for @@ -128,17 +128,15 @@
|
| Methods defined here:
|
- | writerow(self, object, /)
- | writerow(iterable)
+ | writerow(self, row, /)
+ | Construct and write a CSV record from an iterable of fields.
|
- | Construct and write a CSV record from an iterable of fields. Non-string
- | elements will be converted to string.
+ | Non-string elements will be converted to string.
|
- | writerows(self, object, /)
- | writerows(iterable of iterables)
+ | writerows(self, rows, /)
+ | Construct and write a series of iterables to a csv file.
|
- | Construct and write a series of iterables to a csv file. Non-string
- | elements will be converted to string.
+ | Non-string elements will be converted to string.
|
| ----------------------------------------------------------------------
| Data descriptors defined here: |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…GH-137987) The csv.register_dialect() docstring no longer imply that it returns a dialect. All functions have now signatures. (cherry picked from commit aa1dbd4dde32951de2e7438b56d6761001604ee2) Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: maurycy <[email protected]>
Sorry, @serhiy-storchaka, I could not cleanly backport this to
|
GH-138107 is a backport of this pull request to the 3.14 branch. |
…ythonGH-137987) The csv.register_dialect() docstring no longer imply that it returns a dialect. All functions have now signatures. (cherry picked from commit aa1dbd4) Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: maurycy <[email protected]>
GH-138108 is a backport of this pull request to the 3.13 branch. |
…7987) (GH-138108) The csv.register_dialect() docstring no longer imply that it returns a dialect. All functions have now signatures. (cherry picked from commit aa1dbd4) Co-authored-by: maurycy <[email protected]>
…tuations docs: add news entry for TracebackException punctuation fix style: remove trailing whitespace in traceback.py Update 2025-08-24-11-42-38.gh-issue-137716.7-Mtj-.rst Update 2025-08-24-11-42-38.gh-issue-137716.7-Mtj-.rst refactor: improve suggestion message computation and punctuation handling style: remove trailing whitespace in traceback.py pythongh-137986: Fix and improve the csv functions docstrings (pythonGH-137987) The csv.register_dialect() docstring no longer imply that it returns a dialect. All functions have now signatures. Co-authored-by: maurycy <[email protected]> pythongh-135261: bring back CI job for testing OpenSSL 1.1.1w (python#135262) This partially reverts commit d83e30c by bringing back the CI job for testing OpenSSL 1.1.1w. Despite this version being upstream EOL, the rationale for keeping it as follows: - It most resembles other 1.1.1-work-a-like ssl APIs supported by important vendors. - Python officially requires OpenSSL 1.1.1 or later, although OpenSSL 3.0 or later is recommended for cryptographic modules. Since changing the build requirements requires a transition period, we need to keep testing the allowed versions. - The code base still contains calls to OpenSSL functions that are deprecated since OpenSSL 3.0 as well as `ifdef` blocks constrained to OpenSSL 1.1.1.
The csv.register_dialect() docstring no longer imply that it returns a dialect.
All functions have now signatures.