Skip to content

Support dependencies in inline script metadata (PEP 723) #1043

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

Open
mkniewallner opened this issue Jan 28, 2025 · 0 comments
Open

Support dependencies in inline script metadata (PEP 723) #1043

mkniewallner opened this issue Jan 28, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@mkniewallner
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Inline script metadata allow defining dependencies in Python files, that are scoped to a specific module and independents from a project. Although not easy, it could be nice to support this.

Describe the solution you would like

I'm not fully sure how this could be implemented at this time, TBH. Since the dependencies are independent from the project, for each script that contains inline script dependencies, this would imply either:

  • having a dedicated virtual environment where we detect inline script metadata
  • having a "degraded" mode where we try to guess the module name from the package name (and require users to set it manually if this doesn't match)

Technically, even if the dependencies are scoped to specific files, it's still possible to import modules from other scripts, so deptry would need to check for dependencies usages in all files used by the script, which makes things a bit complex, depending on the architecture of the module (if this ends up importing from parent modules for instance).

Additional context

It really doesn't seem that straightforward to support this, so maybe we'll dim that too complex to implement.

Creating this issue made me realise that we should maybe ignore files that contain inline script metadata, when we extract imports, as they likely are scripts that are independent from the project (even though I would expect most users to use a dedicated directory for those scripts, so maybe not too problematic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant