Skip to content

Commit

Permalink
[3.12] tarfile: Fix positional-only syntax in docs (GH-105770) (#105773)
Browse files Browse the repository at this point in the history
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.
(cherry picked from commit 5cdd5ba)

Co-authored-by: Jelle Zijlstra <[email protected]>
  • Loading branch information
miss-islington and JelleZijlstra authored Jun 16, 2023
1 parent 0cb670f commit f94cb78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Doc/library/tarfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,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.
Expand All @@ -923,13 +923,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.

Expand All @@ -946,7 +946,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:
Expand Down

0 comments on commit f94cb78

Please sign in to comment.