This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: io.[Text]IOBase.seek doesn't take keyword parameter - revisited
Type: Stage:
Components: Documentation Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: andymaier, docs@python, methane, tomerv
Priority: normal Keywords:

Created on 2020-09-03 01:32 by andymaier, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg376272 - (view) Author: Andy Maier (andymaier) * Date: 2020-09-03 01:32
I stumbled across the problem reported in https://bugs.python.org/issue25030 on Python 3.8:

>>> with open('x.txt', 'a') as fp:
...   fp.seek(0, whence=os.SEEK_END)
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: seek() takes no keyword arguments

Which I coded with a keyword argument because the documentation says so:

   seek(offset, whence=SEEK_SET)

See https://docs.python.org/3.8/library/io.html#io.IOBase.seek

The fix for issue issue25030 changed the documentation to:

   seek(offset[, whence])

and supposedly was integrated into 2.7, 3.4, and the default branch back then.

It seems the fix got lost?
msg376273 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-09-03 02:35
For the record, https://github.com/python/cpython/pull/14691/files reintroduced `whence=SEEK_SET`.
msg376274 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-09-03 02:36
Since we have positional-only argument, can we document it as `seek(offset, whence=SEEK_SET, /)`?
msg376277 - (view) Author: Andy Maier (andymaier) * Date: 2020-09-03 04:19
Thanks for referencing the PR that reintroduced the old way of documenting it.

From my perspective, the proposal is fine. There are already some cases where it is documented like that, e.g. str.removeprefix(prefix, /).
msg404569 - (view) Author: Tomer Vromen (tomerv) * Date: 2021-10-21 05:52
Just wanted to add that I encountered this today, went to file a ticket, and found this one. I'm fine with either style of documentation.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85864
2021-10-21 05:52:51tomervsetnosy: + tomerv
messages: + msg404569
2020-09-03 04:19:41andymaiersetmessages: + msg376277
2020-09-03 02:36:44methanesetmessages: + msg376274
2020-09-03 02:35:52methanesetnosy: + methane
messages: + msg376273
2020-09-03 01:32:40andymaiercreate