Skip to content

convert shutil._PathReturn to a type parameter? #13508

Open
@dpinol

Description

Since shutil._PathReturn is defined as Any, it may hide type errors to mypy-like tools. E.g in the following code, mypy will not detect that f function is invoked with an str argument instead of a Path.

import shutil
from pathlib import Path


def f(p: Path) -> None:
    pass


def cp(target: str | Path) -> None:
    p = shutil.copy("/src", target)
    return f(p)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: improvementImprove/refactor existing annotations, other stubs issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions