Registry / type-stubs / types-babel

types-babel

JSON →
library2.11.0.15pypypi✓ verified 26d ago

types-babel provides PEP 561 type stubs for the babel package. It allows type-checking tools like MyPy, Pyright, and PyCharm to analyze code that uses the babel library. The current version is 2.11.0.15. As part of the Typeshed project, updates to these stubs are frequent, driven by community contributions and are released to PyPI up to once a day when changes are made.

pip install types-babel
INSTALL
IMPORT
SIG · TYPES-BABEL
T
types-babel
type-stubspythonv2.11.0.15
Install
1.7s avg
Import
—
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.11.0.15 · 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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.6MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

format_date
✓ from babel_stubs.dates import format_date
✗ from babel-stubs.dates import format_date

This quickstart demonstrates how to use a function from the `babel` library (`format_date`) and implicitly leverage the type annotations provided by `types-babel` when running a type checker like MyPy. Ensure you have both `babel` and `mypy` installed. If your `babel` version is 2.12.1 or newer, `types-babel` is not needed.

from datetime import date from babel.dates import format_date def main(): today = date(2026, 4, 12) # types-babel provides type information for functions like format_date formatted_today: str = format_date(today, locale='en_US') print(f"Today is: {formatted_today}") # Example of a type error (uncomment to see mypy in action): # invalid_type: int = format_date(today, locale='en_US') if __name__ == '__main__': main() # To run type checking, install mypy and babel: # pip install babel mypy # Then, run: mypy your_script_name.py
Debug
Known issues
breakingThe `babel` package itself now includes its own type annotations starting from version 2.12.1. If you are using `babel` version 2.12.1 or newer, you should uninstall `types-babel` to avoid conflicts and ensure accurate type checking, as the native types are preferred.
fix
Uninstall `types-babel`: `pip uninstall types-babel`.
affects: babel >= 2.12.1
gotchaVersion compatibility is crucial. The version number of `types-babel` (e.g., `2.11.0.x`) corresponds to the version of the `babel` runtime package it stubs (e.g., `babel==2.11.*`). Using mismatched versions can lead to incorrect or incomplete type checking results.
fix
Ensure that the major and minor version of `types-babel` closely matches your installed `babel` package version (e.g., `types-babel==2.11.x` for `babel==2.11.y`).
affects: <= 2.11.0 of types-babel with any babel version
gotcha`types-babel` is currently marked as a 'partial' stub package. This means that not all modules, classes, or functions within the `babel` library may have complete type annotations. Type checkers might infer `Any` for unannotated parts, potentially missing errors.
fix
Refer to the typeshed repository for details on the completeness of stubs. Contributions to complete missing annotations are welcome in typeshed.
affects: All versions of types-babel
gotchaTypeshed, the source for `types-babel`, supports specific Python versions (currently 3.10 to 3.14). Ensure your Python environment is compatible with both the `types-babel` stubs and the `babel` runtime library. For example, `babel` 2.15 and newer requires Python 3.8 or newer.
fix
Verify your Python version against the typeshed and `babel` documentation. Upgrade or downgrade your Python environment as necessary.
affects: All versions
Upgrade
Version history
2.11.0.15latest on PyPI · released Jul 20, 2023
Audit
Dependencies
babelrequiredProvides the runtime functionality for which these are type stubs.
Agent activity
40 hits · last 30 days
node
32
OpenAI (training)
1
Resources