Django
,Python
,UV
🚜 Using Claude 3.5 Sonnet to refactor one of Brian Okken's Python projects
Brian Okken posted and published his Top pytest Plugins script and then a follow-up post, Finding the top pytest plugins, which was pretty cool.
I have written a few throw-away scripts, which William Vincent wrote about and updated a few times in the Top 10 Django Third-Party Packages (2024) and The 10 Most-Used Django Packages (2024).
These efforts are powered by Hugo van Kemenade’s excellent Top PyPI Packages.
This inspired me to fork Brian’s top-pytest-plugins project, which I updated to support passing in other package names like “django” to get a rough estimate of monthly package downloads.
The refactored project is jefftriplett/top-python-packages.
Please note: Looking at the package name doesn’t scale as well for projects that have their own Trove classifiers. For a project like pytest, it works well. Many of the top packages may not even have Django in their name for a project like Django. Some projects may even actively discourage a project from using their project in their package’s name for trademark reasons. So, YMMV applies here.
Prompts
I added uv run
support, which I have written about a lot lately.
I also copied the top_pytest.py
file into a Claude 3.5 Sonnet session, and I let it handle the whole refactor. It even handled adding the PEP 723 new package dependencies without me asking it to.
In case it’s useful to anyone, here are my prompts:
## Prompt:
Please update this script to use a rich table.
## Prompt:
Please update the table styles to be ascii so I can copy and paste it into a markdown doc
## Prompt:
Please remove the description column
## Prompt:
Please change all PyTest and pytest references to Django and django
## Prompt:
Please add back `if 'django' in project.lower() and 'django' != project.lower():`
## Prompt:
please remove the \*# Export to markdown section. I can just pipe the output \*
## Prompt:
Please add the typer library.
## Prompt:
Please remove days and limit
## Prompt:
Please refactor the script to allow me to pass the package name instead of django. You can default to django though.
This way I can pass pytest or flask or other projects.
## Prompt:
Please change the default Table box type to MARKDOWN
Outro
I don’t usually write about Claude or prompts, but the tool has been handy lately.
If you have had some similar successes, let me know. I have been exploring some rabbit holes, and it’s changing the way I approach solving problems.
Sunday August 25, 2024