Skip to content
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

Path.relative_to() taking multiple arguments could be better documented #78707

Closed
anntzer mannequin opened this issue Aug 28, 2018 · 3 comments · Fixed by #94469
Closed

Path.relative_to() taking multiple arguments could be better documented #78707

anntzer mannequin opened this issue Aug 28, 2018 · 3 comments · Fixed by #94469
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Aug 28, 2018

BPO 34526
Nosy @anntzer, @barneygale
PRs
  • bpo-34526:[doc] Add description and examples of multiple arguments for Path.relative_to #31368
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2018-08-28.08:42:29.205>
    labels = ['easy', '3.11', '3.9', '3.10', 'docs']
    title = 'Path.relative_to() taking multiple arguments could be better documented'
    updated_at = <Date 2022-02-16.08:01:06.637>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2022-02-16.08:01:06.637>
    actor = 'python-dev'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2018-08-28.08:42:29.205>
    creator = 'Antony.Lee'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34526
    keywords = ['patch', 'easy']
    message_count = 1.0
    messages = ['324224']
    nosy_count = 4.0
    nosy_names = ['docs@python', 'python-dev', 'Antony.Lee', 'barneygale']
    pr_nums = ['31368']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue34526'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    @anntzer
    Copy link
    Mannequin Author

    anntzer mannequin commented Aug 28, 2018

    Currently, the docs for Path.relative_to read

        PurePath.relative_to(*other)
        Compute a version of this path relative to the path represented by other. If its impossible, ValueError is raised: (examples follow)

    It's a bit confusing why other is a star-args, especially as no example actually passes more than one argument to relative_to.

    The docstring is a tiny bit clearer:

    Return the relative path to another path identified by the passed
    arguments.  If the operation is not possible (because this is not
    a subpath of the other path), raise ValueError.
    

    Effectively, a Path is constructed from all *other args and used as base for the computation of the relative path. It looks a bit like a misfeature to me, but at least it could be better documented (e.g. by adding Path("/tmp/foo/bar").relative_to("/tmp", "foo") == Path("bar") as example in the docs).

    @anntzer anntzer mannequin added the 3.7 (EOL) end of life label Aug 28, 2018
    @anntzer anntzer mannequin assigned docspython Aug 28, 2018
    @anntzer anntzer mannequin added the docs Documentation in the Doc dir label Aug 28, 2018
    @iritkatriel iritkatriel added easy 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes and removed 3.7 (EOL) end of life labels Jan 19, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @barneygale
    Copy link
    Contributor

    I think this is a mis-feature and we should look at deprecating + removing it, rather than documenting it.

    Consider that pathlib has many other methods that accept a single other path, like rename(), replace(), symlink_to() and hardlink_to().

    The only methods that should support *args should be joinpath() and the PurePath initialiser IMO.

    @JelleZijlstra
    Copy link
    Member

    Agree that this is a misfeature. We'll have to go through a deprecation cycle to remove it though, since it's at least kind of documented.

    barneygale added a commit to barneygale/cpython that referenced this issue Jun 30, 2022
    …ive_to()`
    
    This brings `relative_to()` and `is_relative_to()` more in line with other
    pathlib methods like `rename()` and `symlink_to()`.
    barneygale added a commit to barneygale/cpython that referenced this issue Nov 25, 2022
    miss-islington pushed a commit that referenced this issue Dec 17, 2022
    …()` (GH-94469)
    
    This brings `relative_to()` and `is_relative_to()` more in line with other pathlib methods like `rename()` and `symlink_to()`.
    
    Resolves #78707.
    shihai1991 added a commit to shihai1991/cpython that referenced this issue Dec 18, 2022
    * origin/main: (1306 commits)
      Correct CVE-2020-10735 documentation (python#100306)
      pythongh-100272: Fix JSON serialization of OrderedDict (pythonGH-100273)
      pythongh-93649: Split tracemalloc tests from _testcapimodule.c (python#99551)
      Docs: Use `PY_VERSION_HEX` for version comparison (python#100179)
      pythongh-97909: Fix markup for `PyMethodDef` members (python#100089)
      pythongh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (python#99890)
      pythongh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (python#99890)
      pythonGH-98831: Add DECREF_INPUTS(), expanding to DECREF() each stack input (python#100205)
      pythongh-78707: deprecate passing >1 argument to `PurePath.[is_]relative_to()` (pythonGH-94469)
      pythongh-99540: Constant hash for _PyNone_Type to aid reproducibility (pythonGH-99541)
      pythongh-100039: enhance __signature__ to work with str and callables (pythonGH-100168)
      pythongh-99830: asyncio: Document returns of remove_{reader,writer} (python#100302)
      "Compound statement" docs: Fix with-statement step indexing (python#100286)
      pythonGH-90043: Handle NaNs in COMPARE_OP_FLOAT_JUMP (pythonGH-100278)
      Improve stats presentation for calls. (pythonGH-100274)
      Better stats for `LOAD_ATTR` and `STORE_ATTR` (pythonGH-100295)
      pythongh-81057: Move the Cached Parser Dummy Name to _PyRuntimeState (python#100277)
      Document that zipfile's pwd parameter is a `bytes` object (python#100209)
      pythongh-99767: mark `PyTypeObject.tp_watched` as internal use only in table (python#100271)
      Fix typo in introduction.rst (python#100266)
      ...
    carljm added a commit to carljm/cpython that referenced this issue Dec 19, 2022
    * main:
      pythongh-89727: Fix os.walk RecursionError on deep trees (python#99803)
      Docs: Don't upload CI artifacts (python#100330)
      pythongh-94912: Added marker for non-standard coroutine function detection (python#99247)
      Correct CVE-2020-10735 documentation (python#100306)
      pythongh-100272: Fix JSON serialization of OrderedDict (pythonGH-100273)
      pythongh-93649: Split tracemalloc tests from _testcapimodule.c (python#99551)
      Docs: Use `PY_VERSION_HEX` for version comparison (python#100179)
      pythongh-97909: Fix markup for `PyMethodDef` members (python#100089)
      pythongh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (python#99890)
      pythongh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (python#99890)
      pythonGH-98831: Add DECREF_INPUTS(), expanding to DECREF() each stack input (python#100205)
      pythongh-78707: deprecate passing >1 argument to `PurePath.[is_]relative_to()` (pythonGH-94469)
    barneygale added a commit to barneygale/cpython that referenced this issue May 8, 2024
    … arguments
    
    Remove support for supplying additional positional arguments to
    `PurePath.relative_to()` and `is_relative_to()`. This has been deprecated
    since Python 3.12.
    barneygale added a commit to barneygale/cpython that referenced this issue May 8, 2024
    barneygale added a commit to barneygale/cpython that referenced this issue May 10, 2024
    barneygale added a commit that referenced this issue May 10, 2024
    …ents (#118780)
    
    Remove support for supplying additional positional arguments to
    `PurePath.relative_to()` and `is_relative_to()`. This has been deprecated
    since Python 3.12.
    estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
    … arguments (python#118780)
    
    Remove support for supplying additional positional arguments to
    `PurePath.relative_to()` and `is_relative_to()`. This has been deprecated
    since Python 3.12.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy
    Projects
    None yet
    Development

    Successfully merging a pull request may close this issue.

    3 participants