Audit and remove unused dependencies across base/local/production - #1636
Conversation
Grep-audited every direct backend dependency across opencontractserver/, config/, scripts, compose, Dockerfiles, settings, and CI workflows. Dropped from requirements/base.txt (0 verifiable refs in code): python-slugify, django-model-utils, pandas, tiktoken, jsonschema (pandas, tiktoken, jsonschema remain installed transitively via plasmapdf, pydantic-ai-slim[openai], and mcp respectively.) Dropped from requirements/local.txt (0 refs, none in pre-commit/CI): Werkzeug[watchdog], ipdb, pytest-sugar, pylint-django, pylint-celery (pylint is never invoked by pre-commit, scripts, or CI — .pylintrc was the only consumer.) Dropped from requirements/production.txt: django-anymail[mailgun] — settings block in production.py is fully commented out. Deduped: django-extensions==4.1 was redundantly listed in both base.txt and local.txt; kept only in local.txt (the only place it is added to INSTALLED_APPS). Moved to local.txt as test-only: pytesseract — only used by tests/test_pdf_redaction.py to mirror the docling-parser microservice OCR; production OCR runs in the docling-parser container. Also dropped tesseract-ocr/tesseract-ocr-eng apt installs from compose/production/django/Dockerfile. Deleted orphan requirement files: requirements/filetypes/docx.txt (mammoth, docx pipeline not active) requirements/ingestors/nlm_ingest.txt (file body was '# pass') requirements/processors/gliner.txt (only commented placeholders) .pylintrc (pylint not run anywhere) Updated .pre-commit-config.yaml mypy hook additional_dependencies to match the trimmed requirements (removed django-model-utils, pandas, tiktoken, jsonschema, python-slugify). Snyk pins duplicated across all three requirements files are intentionally left in place per the existing comment in production.txt (Snyk does not understand -r inheritance). Validated via pip install --dry-run that the resolved install set is unchanged for any directly imported package; pandas/tiktoken/jsonschema remain present via transitive deps. https://claude.ai/code/session_01KTbftXBiTyrn8Xhi9FrfF4
Code ReviewOverviewThis PR performs a targeted dependency audit, removing ~16 direct packages from What's done correctly
Issues and Suggestions1. Minor:
# line 370
import pytesseractIf someone runs tests using import shutil
import unittest
@unittest.skipUnless(shutil.which("tesseract"), "tesseract binary not available")
class TestPDFRedaction(TestCase):
...Not blocking since the standard test invocation ( 2. Minor: The anymail block in # To enable Mailgun email: add django-anymail[mailgun] to requirements/production.txt
# INSTALLED_APPS += ["anymail"]This is entirely optional — just improves discoverability. 3. Trivial: CHANGELOG entry formatting The single mega-paragraph changelog entry would be easier to scan as bullet points, consistent with how other entries in the same file are formatted. The content is excellent; just the presentation is denser than the surrounding entries. No Issues Found With
SummaryThis is a clean, well-researched maintenance PR. All removals are verified against the actual codebase. The |
…dependencies-8tJm3
…, bullet CHANGELOG - Add @skipUnless guards to test_pdf_redactor_with_ocr_verification and test_pdf_redactor_with_specific_tokens so they degrade cleanly when pytesseract or the tesseract binary is absent (now that pytesseract is test-only). The Docker test image still installs both, so CI behaviour is unchanged. - Drop a breadcrumb comment in config/settings/production.py pointing future operators at re-adding django-anymail[mailgun] to requirements/production.txt before uncommenting the Mailgun block. - Reformat the dependency-audit CHANGELOG entry from one mega-paragraph into nested bullets to match the surrounding entry style.
| import os | ||
| import random | ||
| import shutil | ||
| import unittest |
Code Review: Dependency Audit and CleanupOverviewThis is a well-scoped dependency audit removing unused packages across Items to Verify1.
If any results appear, the removal will cause an 2. Django ships 3.
4. Confirm The PR description says the system binary is "installed in 5. Operators who have already deployed and uncommented the Anymail block in their Positive Notes
Minor Nits
SummaryThe audit approach is sound and the execution is clean. The main risk is false negatives from a grep-only audit on packages that surface through model inheritance or indirect imports -- |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Comprehensive dependency audit removing unused and vestigial packages from
requirements/base.txt,requirements/local.txt, andrequirements/production.txt. Grep-audited all direct dependencies against codebase references inopencontractserver/,config/, scripts, compose, Dockerfiles, settings, and CI workflows.Key Changes
Removed from
base.txt(~10 direct deps):python-slugify— zero verifiable code referencespandas— zero verifiable code referencesdjango-model-utils— zero verifiable code referencestiktoken— zero verifiable code referencesjsonschema— zero verifiable code referencesdjango-extensions— moved tolocal.txt(only used inconfig/settings/local.py)pytesseract— moved tolocal.txt(only used by test-onlytest_pdf_redaction.py; production OCR runs in docling-parser container)Removed from
local.txt(~5 direct deps):Werkzeug[watchdog]— zero verifiable code referencesipdb— zero verifiable code referencespytest-sugar— zero verifiable code referencespylint-django— zero verifiable code referencespylint-celery— zero verifiable code referencesRemoved from
production.txt:django-anymail[mailgun]— settings block was fully commented outDeleted orphan requirement files:
requirements/filetypes/docx.txt(contained onlymammoth==1.11.0for inactive docx pipeline)requirements/ingestors/nlm_ingest.txt(body was literally# pass)requirements/processors/gliner.txt(body was only commented placeholders).pylintrc(pylint is not invoked by pre-commit, CI, or any script)Updated
compose/production/django/Dockerfile:tesseract-ocrandtesseract-ocr-engapt installs (pytesseract moved to test-only, production OCR runs in docling-parser container)Updated
.pre-commit-config.yaml:additional_dependencieslist to keep in lockstep withrequirements/Implementation Details
pytesseractmoved tolocal.txtwith explanatory comment: "Test-only — OCR pipeline used by tests/test_pdf_redaction.py to verify the docling-parser microservice's OCR behavior. Production OCR runs in the docling-parser container, so this is not needed in base.txt."django-extensionsdeduplicated (was redundantly listed in bothbase.txtandlocal.txt; kept only inlocal.txtsince it is only added toINSTALLED_APPSinconfig/settings/local.py)production.txtBenefits
https://claude.ai/code/session_01KTbftXBiTyrn8Xhi9FrfF4