Is there something like a dead-import detector for Python? I just realized we have a package in our requirements that never gets imported anymore, which I didn't notice for months.
=> More informations about this toot | More toots from pamelafox@fosstodon.org
@pamelafox https://github.com/fredrikaverpil/creosote might be helpful :)
=> More informations about this toot | More toots from wirthual@fosstodon.org
@wirthual I tried it out, lots of false positives, but at least its easier to scan the shorter list to confirm I'm using all them.
=> More informations about this toot | More toots from pamelafox@fosstodon.org
@pamelafox I see, there's also https://github.com/tweag/FawltyDeps by @jherland
=> More informations about this toot | More toots from wirthual@fosstodon.org
@wirthual @pamelafox ...and I'm eager to hear how it's working for you. 🤓
=> More informations about this toot | More toots from jherland@mastodon.social
@jherland @wirthual Okay so yours worked better, once I explicitly told it to use requirements.in versus requirements.txt
Interestingly, it tells me that 'typing_extensions' is an undeclared dependency.. Ah and I only got away with it because its in my transitive dependencies, due to so many packages using it.
Very cool!
=> More informations about this toot | More toots from pamelafox@fosstodon.org
@jherland @wirthual I think it missed the dead-import that I identified manually, opentelemetry-instrumentation-requests
=> More informations about this toot | More toots from pamelafox@fosstodon.org
@wirthual @jherland lol its funny theyre both named after monty python skits. trying now!
=> More informations about this toot | More toots from pamelafox@fosstodon.org
@pamelafox I guess you could:
pip install .
your project.pip freeze > new_requirements.txt
And then compare both requirements files. The versions of packages will be different for sure, and you might have some different transitive dependencies, but it should give you a good start.
=> More informations about this toot | More toots from sergi@floss.social
@pamelafox I think Ruff or Pyflakes might do that? I seem to remember being pleasantly surprised by it some weeks ago when using one (or both?) of those tools.
=> More informations about this toot | More toots from fergus@cosroe.com
@fergus @pamelafox yeah, think my pre-commit (flake8 bit of it) notifies me of unused imports.
=> More informations about this toot | More toots from belfinwe@social.linux.pizza
@belfinwe @fergus That's within a file, right? I meant a package thats in my requirements thats unused across the whole package. I tried the creosote tool that was suggested, and that did a decent job, though lots of false positives.
=> More informations about this toot | More toots from pamelafox@fosstodon.org
@pamelafox @belfinwe Ah right -- didn't know about creosote, but it looks useful!
=> More informations about this toot | More toots from fergus@cosroe.com This content has been proxied by September (3851b).Proxy Information
text/gemini