Skip to content

Dependency inference for resources loaded via importlib.resources.files #21191

Open
@grihabor

Description

@grihabor

The problem

I'm using importlib.resources.files to load resources from python. I'd like to have dependency inference support for resource targets I load.

The solution

It would be nice to have the support implemented in rust.

Specifically, I want the anchor argument to work with an import:

import my_package
from importlib.resources import files 

files(my_package).joinpath('path/to/my_resource.txt')

and __package__:

from importlib.resources import files 

files(__package__).joinpath('path/to/my_resource.txt')

Alternatives

The support could be added in python, but it will be slow and it would duplicate the AST parsing and analysis.

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions