types-qrcode is a type stub package providing external type annotations for the 'qrcode' Python library. It enables static type checkers like Mypy and Pyright to analyze code that uses 'qrcode', ensuring type correctness without altering runtime behavior. This package is part of the Typeshed project, which releases updates frequently (sometimes daily) to maintain alignment with the 'qrcode' library's versions.
pip install types-qrcodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to generate and save a basic QR code using the 'qrcode' library. With 'types-qrcode' installed, a type checker would analyze this code for type correctness. The `qrcode[pil]` installation is crucial for the `img.save()` method to work correctly.
Ensure `qrcode` (and optionally `Pillow` via `qrcode[pil]`) is installed alongside `types-qrcode`.
Keep `types-qrcode` updated to a version compatible with your installed `qrcode` library. Consider using version bounds (e.g., `types-qrcode>=8.2.0,<8.3`) in your `requirements.txt`.
Install `qrcode` with the `pil` extra: `pip install qrcode[pil]`.
Follow QR code design best practices: ensure high contrast (dark modules on a light background, 4:1 ratio minimum), maintain adequate size (at least 2x2 cm for close scans, 10:1 ratio for distance), and avoid excessive customization that obscures the pattern. Test thoroughly before deployment.