Skip to content

feat: allow single file to be used instead of directory#1414

Open
tylerriccio33 wants to merge 8 commits intofpgmaas:mainfrom
tylerriccio33:single-file
Open

feat: allow single file to be used instead of directory#1414
tylerriccio33 wants to merge 8 commits intofpgmaas:mainfrom
tylerriccio33:single-file

Conversation

@tylerriccio33
Copy link

PR Checklist

  • A description of the changes is added to the description of this PR.
  • [] If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

This PR allows a single file to be passed to deptry for analysis. I often find myself creating projects with a single file, and would love to use deptry to root out unused dependencies. I couldn't find a way to allow just a single file so I wrote this PR.

The changes are fairly straightforward, I intercept the single file at the rust level in src/python_file_finder.rs. This could easily be done in python but I'd imagine the authors prefer a unified interface.

Let me know what you think!

P.S. Initially marking this as draft since I had some OS related issues running functional tests. My M1 chip can be dicey...

Old Behavior:
Screenshot 2026-01-06 at 10 02 33 PM

New Behavior:
Screenshot 2026-01-06 at 10 02 01 PM

@tylerriccio33 tylerriccio33 marked this pull request as ready for review January 7, 2026 18:45
@tylerriccio33
Copy link
Author

Anything I can do to push this along?

@fpgmaas
Copy link
Owner

fpgmaas commented Feb 5, 2026

I am not quite sure yet if this is useful enough for it to be merged to main. Can you elaborate why simply running uv run deptry . would not suffice? If it is a single file, deptry would simply return a list of only that file while scanning for files, and then analyze that, right?

@tylerriccio33
Copy link
Author

Occasionally I have other files commingled with the 'main' file. For example, I may have some builder scripts that construct metadata during the package build, but isn't actually required by the 'main' file. Sometimes I'll have a single 'main' file and a single test script. In those 2 cases I will import dev or build dependencies that aren't declared in the pyproject.toml file.

As I say this out loud, maybe there's room to instead, discriminate between regular and dev deps?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments