{"id":6283,"library":"types-emoji","title":"Typing Stubs for Emoji","description":"`types-emoji` provides static type checking definitions for the popular `emoji` Python library. It enables type checkers like MyPy to understand the types used in `emoji.emojize()`, `emoji.demojize()`, and other functions, improving code reliability and developer experience. This package is part of the `typeshed` project, which maintains external type annotations for numerous Python libraries and the standard library. `types-emoji` follows the release cadence of `typeshed`, which is often independent of the runtime `emoji` library's release schedule.","status":"active","version":"2.1.0.3","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","emoji","typeshed","static analysis"],"install":[{"cmd":"pip install types-emoji","lang":"bash","label":"Install typing stubs"},{"cmd":"pip install emoji","lang":"bash","label":"Install runtime library (required for execution)"}],"dependencies":[{"reason":"Runtime library for which these are type stubs.","package":"emoji","optional":false}],"imports":[{"symbol":"emoji","correct":"import emoji"},{"note":"The `emojize` function is part of the `emoji` module, not a top-level import.","wrong":"import emojize","symbol":"emojize","correct":"from emoji import emojize"},{"note":"The `demojize` function is part of the `emoji` module, not a top-level import.","wrong":"import demojize","symbol":"demojize","correct":"from emoji import demojize"}],"quickstart":{"code":"import emoji\nimport os\n\n# Example 1: Convert shortcode to emoji\ntext_with_emoji = emoji.emojize(\"Python is fun :red_heart:\")\nprint(f\"Emojized: {text_with_emoji}\")\n\n# Example 2: Convert emoji to shortcode\ntext_with_shortcode = emoji.demojize(\"Python is fun ❤️\")\nprint(f\"Demojized: {text_with_shortcode}\")\n\n# Example 3: Check if a string contains an emoji\nhas_emoji = emoji.is_emoji(\"👍\")\nprint(f\"Is '👍' an emoji? {has_emoji}\")\n\n# Example 4: Using language-specific shortcodes (e.g., Spanish)\nspanish_text_emojized = emoji.emojize(\"Python es :pulgar_hacia_arriba:\", language='es')\nprint(f\"Spanish emojized: {spanish_text_emojized}\")\n\nspanish_text_demojized = emoji.demojize(\"Python es 👍\", language='es')\nprint(f\"Spanish demojized: {spanish_text_demojized}\")\n\n# Example 5: Using variant for emoji presentation (if supported)\nheart_emoji_type = emoji.emojize(\"Python is fun :red_heart:\", variant=\"emoji_type\")\nprint(f\"Heart emoji type: {heart_emoji_type}\")","lang":"python","description":"This quickstart demonstrates basic usage of the `emoji` library's core functions: `emojize` to convert text shortcodes into Unicode emojis, `demojize` to reverse this process, `is_emoji` to detect emojis, and how to use language-specific shortcodes or presentation variants."},"warnings":[{"fix":"Ensure both `types-emoji` and `emoji` are installed in your environment.","message":"`types-emoji` provides only type hints for static analysis. To execute Python code that uses emoji functionalities, you must also install the actual `emoji` runtime library (e.g., `pip install emoji`).","severity":"gotcha","affected_versions":"All versions of `types-emoji`"},{"fix":"Ideally, align the version bounds of `types-emoji` with your `emoji` runtime library version. Regularly update your type checker and stubs, addressing any new type errors as they arise, or pin `types-emoji` to a specific version if strict stability is required for type checking.","message":"As `types-emoji` is part of `typeshed`, any version bump might introduce changes to type annotations that could cause your code to fail type checking, even if the underlying `emoji` runtime library remains unchanged. This can happen due to more precise type definitions or bug fixes in stubs.","severity":"breaking","affected_versions":"All versions of `types-emoji`"},{"fix":"Pass the appropriate `language` argument to `emojize()` or `demojize()` if you are not using English shortcodes or require alias support.","message":"Emoji shortcodes in `emoji.emojize()` and `emoji.demojize()` default to English. If you intend to use shortcodes from other languages (e.g., Spanish, Portuguese, French) or enable a broader set of aliases, you must explicitly provide the `language` argument (e.g., `language='es'` or `language='alias'`).","severity":"gotcha","affected_versions":"All versions of `emoji` (runtime library)"},{"fix":"Use the `variant` argument if a specific emoji presentation is desired, especially when dealing with mixed environments or older systems.","message":"Some emojis have different Unicode presentation styles (e.g., text vs. emoji presentation). For explicit control over the output, `emoji.emojize()` supports a `variant` argument (e.g., `variant='emoji_type'`).","severity":"gotcha","affected_versions":"All versions of `emoji` (runtime library)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}