$ account adamchainz
django-htmx is a mature, reusable Django library that integrates the htmx JavaScript library with Django. It provides a middleware that parses htmx headers and attaches an `HtmxDetails` object to each request (exposing properties like `boosted`, `current_url`, `target`), a set of HTTP response helpers for htmx interactions (e.g., `push_url`, `reswap`, `HttpResponseClientRedirect`), and template tags (for both Django and Jinja2) to include htmx scripts with version and extension selection. The library also bundles htmx versions 2 and 4 (beta) along with many extensions. It is a focused, well-tested package often used in production Django applications that need to leverage htmx for dynamic UI without writing JavaScript. The architecture is a standard reusable Django app with a clear separation of concerns: middleware for request processing, HTTP utilities for responses, and template tags for asset inclusion. Dependencies are minimal (Django 5.2+, asgiref). This is not a data research or analytics tool; it is purely a backend integration library.
The time-machine library is a Python package designed to mock system time in tests by patching the datetime and time modules at the C level. It provides a versatile API that can be used as a context manager, decorator, or pytest fixture, allowing developers to set a fixed time or simulate time progression. The library supports timezone handling, nesting of time travel contexts, and an escape hatch to access the real time when needed. Additionally, it includes a command-line tool to assist in migrating from the popular freezegun library. The core innovation lies in the C extension (_time_machine.c), which directly manipulates the function pointers of the datetime and time modules to replace them with custom implementations. This approach ensures high performance and comprehensive mocking, affecting all references to these functions throughout the Python process. The Python layer manages the state of active time travels, handles timezone settings via the TZ environment variable, and provides a rich set of features for controlling the simulated time, such as moving to different timestamps or shifting by a delta. The project demonstrates strong engineering practices with comprehensive test coverage, modern development tooling (including pre-commit hooks, linting, and type checking), and careful consideration of cross-platform compatibility. It maintains backward compatibility while introducing improvements, such as making the dateutil dependency optional and adding controls for interpreting naive datetime values. The CLI tool for migration showcases a practical use of the tokenize_rt library for precise source code transformations, reflecting attention to real-world usability.