Registry / type-stubs / types-qrcode

types-qrcode

JSON →
library8.2.0.20260518pypypi✓ verified 24d ago

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-qrcode
INSTALL
IMPORT
SIG · TYPES-QRCODE
T
types-qrcode
type-stubspythonv8.2.0.20260518
Install
2.4s avg
Import
Disk
64MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v8.2.0.20260518 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 92.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.000s · 38MB
64MB installed
● package 64MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

qrcode
import qrcode-stubs
from qrcode-stubs import qrcode

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.

import qrcode # Data to be encoded in the QR code data = "https://www.example.com/your-data-here" # Create QR code instance with desired parameters # version: controls the size of the QR Code (1 to 40). None for auto-sizing. # error_correction: controls the error correction level. # box_size: size of each box (pixel) in the QR Code. # border: thickness of the border (minimum 4). qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_H, # High error correction box_size=10, border=4, ) # Add data to the QR code qr.add_data(data) qr.make(fit=True) # Create an image from the QR code instance # Pillow (PIL) is required for saving as an image file like PNG img = qr.make_image(fill_color="black", back_color="white") # Save the image # In a real application, you might use os.path.join for paths output_filename = "my_qrcode.png" img.save(output_filename) print(f"QR Code saved to {output_filename}")
Debug
Known issues
gotchaThe `types-qrcode` package provides only type hints; it does not contain any runtime code. The actual `qrcode` library must be installed separately (e.g., `pip install qrcode`) for your application to function.
fix
Ensure `qrcode` (and optionally `Pillow` via `qrcode[pil]`) is installed alongside `types-qrcode`.
affects: All versions
breakingType stubs are versioned to match the runtime library. If the `qrcode` library undergoes a major version update (e.g., from 8.x to 9.x), the `types-qrcode` stubs for the older version might become incompatible, leading to type-checking errors even if your runtime code still works.
fix
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`.
affects: All versions, especially across major `qrcode` updates
gotchaFor 'qrcode' to generate and save images (e.g., PNG, JPEG), the Pillow library is required. This is typically installed with `pip install qrcode[pil]`.
fix
Install `qrcode` with the `pil` extra: `pip install qrcode[pil]`.
affects: All versions
gotchaEffective QR code usage involves design considerations (contrast, size, content). Type checkers won't flag poor design choices like low contrast (dark QR on dark background), inverted colors (light QR on dark background), or excessively small QR codes, which can severely impact scannability and user experience. Always test generated QR codes with multiple scanners.
fix
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.
affects: All versions of qrcode and types-qrcode
Upgrade
Version history
8.2.0.20260518latest on PyPI · released May 18, 2026
Audit
Dependencies
qrcoderequiredProvides the actual QR code generation functionality; types-qrcode only provides type hints for it.
PillowoptionalRequired by the 'qrcode' library for saving QR codes as image files (e.g., PNG). Installed via 'qrcode[pil]'.
Agent activity
35 hits · last 30 days
node
30
OpenAI (training)
1
Resources
types-qrcode — pip install types-qrcode · libregistry