Ancestors

Toot

Written by Pamela Fox on 2024-12-11 at 17:31

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

Descendants

Written by Wirthual on 2024-12-11 at 17:35

@pamelafox https://github.com/fredrikaverpil/creosote might be helpful :)

=> More informations about this toot | More toots from wirthual@fosstodon.org

Written by Pamela Fox on 2024-12-11 at 18:19

@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

Written by Wirthual on 2024-12-11 at 18:45

@pamelafox I see, there's also https://github.com/tweag/FawltyDeps by @jherland

=> More informations about this toot | More toots from wirthual@fosstodon.org

Written by Johan Herland on 2024-12-11 at 19:06

@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

Written by Pamela Fox on 2024-12-11 at 20:57

@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

Written by Pamela Fox on 2024-12-11 at 20:59

@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

Written by Pamela Fox on 2024-12-11 at 20:52

@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

Written by Sergi on 2024-12-11 at 19:16

@pamelafox I guess you could:

  1. Create a clean venv (or uninstall all packages of current venv).

  1. pip install . your project.

  1. 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

Written by Fergus on 2024-12-11 at 20:06

@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

Written by belfinwe 🇳🇴 on 2024-12-11 at 20:29

@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

Written by Pamela Fox on 2024-12-11 at 20:51

@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

Written by Fergus on 2024-12-11 at 22:10

@pamelafox @belfinwe Ah right -- didn't know about creosote, but it looks useful!

=> More informations about this toot | More toots from fergus@cosroe.com

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113635378486437735
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
339.414407 milliseconds
Gemini-to-HTML Time
2.227091 milliseconds

This content has been proxied by September (3851b).