Skip to content

Add pathlib.Path.metadata() and soft-deprecate info #140127

Description

@barneygale

Feature or enhancement

Proposal:

I propose we add a pathlib.Path.metadata() method that requires a keyword-only cached argument, e.g.:

>>> m = pathlib.Path('README.txt').metadata(cached=True)
>>> m
Metadata('README.txt')
>>> m.is_file()
True

If cached is True, the method may return a Metadata object that was previously fetched and cached. If False, the return value is always up-to-date.

pathlib.Path.info should be soft-deprecated; its implementation should call self.metadata(cached=True)

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/ergonomics-of-new-pathlib-path-scandir/71721/70

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

    stdlibStandard Library Python modules in the Lib/ directorytopic-pathlibtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions