]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
tarfile: Fix positional-only syntax in docs (GH-105770)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Wed, 14 Jun 2023 07:26:48 +0000 (00:26 -0700)
committerGitHub <noreply@github.com>
Wed, 14 Jun 2023 07:26:48 +0000 (09:26 +0200)
The syntax used in the current docs (a / before any args) is invalid.

I think the right approach is for the arguments to arbitrary
filter functions to be treated as positional-only, meaning that users
can supply filter functions with any names for the argument. tarfile.py
only calls the filter function with positional arguments.

Doc/library/tarfile.rst

index 2f330f018a48be08188fa8c587ba2afa676c11b8..fd4820e78d68d17319b0496bb22468a68f35f186 100644 (file)
@@ -908,7 +908,7 @@ can be:
   path to where the archive is extracted (i.e. the same path is used for all
   members)::
 
-      filter(/, member: TarInfo, path: str) -> TarInfo | None
+      filter(member: TarInfo, path: str, /) -> TarInfo | None
 
   The callable is called just before each member is extracted, so it can
   take the current state of the disk into account.
@@ -928,13 +928,13 @@ Default named filters
 The pre-defined, named filters are available as functions, so they can be
 reused in custom filters:
 
-.. function:: fully_trusted_filter(/, member, path)
+.. function:: fully_trusted_filter(member, path)
 
    Return *member* unchanged.
 
    This implements the ``'fully_trusted'`` filter.
 
-.. function:: tar_filter(/, member, path)
+.. function:: tar_filter(member, path)
 
   Implements the ``'tar'`` filter.
 
@@ -951,7 +951,7 @@ reused in custom filters:
 
   Return the modified ``TarInfo`` member.
 
-.. function:: data_filter(/, member, path)
+.. function:: data_filter(member, path)
 
   Implements the ``'data'`` filter.
   In addition to what ``tar_filter`` does: