Skip to content

Conversation

@goodtune
Copy link
Collaborator

@goodtune goodtune commented Aug 31, 2025

Summary

Modernize the codebase by removing compatibility code for old Django and Python versions, targeting Django 4.2+ and Python 3.8+ as per the project's compatibility guarantees.

Changes Made

Python 2.7 Style super() Calls → Modern Python 3+

  • 30 super() calls modernized across 14 files
  • Changed super(ClassName, self).method_name(...)super().method_name(...)
  • No functional changes, only syntax modernization

Removed Defensive Imports for Old Versions

  • Remove try/except ImportError for django.apps (always available in Django 4.2+)
  • Remove try/except ImportError for django.db.models.indexes.Index (always available in Django 4.2+)
  • Remove try/except ImportError for StringIO (Python 3.8+ always uses io.StringIO)
  • Remove allow_syncdb method (Django 4.2+ only uses allow_migrate)
  • Remove Django < 1.7 model compatibility code in router
  • Remove from __future__ imports (not needed in Python 3.8+)

Documentation and Comment Updates

  • Update test comments from "Django 1.7+" to just "Django" (no longer version-specific)
  • Update documentation links from Django 1.8/1.11 to Django 4.2
  • Fix misleading comment about server-side cursor support
  • Move imports from inside methods to top of file (old circular import workarounds no longer needed)

What Was Preserved

  • psycopg/psycopg2 imports preserved - these provide choice between PostgreSQL drivers (aligns with Django's approach)
  • All existing functionality maintained
  • Migration files left untouched (auto-generated by Django)

Test Plan

  • All imports successful - syntax is valid
  • Documentation URLs verified to return HTTP 200
  • Code formatting and import sorting applied
  • Full test suite

The codebase is now fully modernized for the current Django LTS (4.2+) and Python 3.8+ target versions while maintaining all existing functionality.

- Replace all `super(ClassName, self).method_name(...)` with `super().method_name(...)`
- Updated 30 `super()` calls across 14 files
- Maintains compatibility with current Django and Python versions
- No functional changes, only syntax modernization
- Remove `try/except ImportError` for `django.apps` (Django 4.2+ has this)
- Remove `try/except ImportError` for `django.db.models.indexes.Index` (Django 4.2+ has this)
- Remove `try/except ImportError` for `StringIO` (Python 3.8+ uses `io.StringIO`)
- Remove `allow_syncdb` method (Django 4.2+ only uses `allow_migrate`)
- Remove Django < 1.7 model compatibility code in router
- Update comments referencing old Django versions
- Remove `from __future__` imports (not needed in Python 3.8+)
- Update test comment from 'Django 1.7+' to just 'Django' (no longer version-specific)
- Update documentation links from Django 1.8/1.11 to Django 4.2
- Remove version-specific language that implied these were new features
@goodtune goodtune merged commit 0344351 into bernardopires:master Sep 1, 2025
26 checks passed
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.

1 participant