{"id":5533,"library":"types-enum34","title":"Typing stubs for enum34","description":"types-enum34 is a PEP 561 type stub package providing static type information for the `enum34` library. The `enum34` library itself is a backport of Python 3.4's standard library `enum` module, enabling enumeration support for older Python versions (2.4-3.3). This stub package allows type-checking tools like MyPy, PyCharm, and Pytype to analyze code that uses `enum34`. The current version is 1.1.8, released in January 2022, and its development cadence follows contributions to the `typeshed` project.","status":"active","version":"1.1.8","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed/tree/master/stubs/enum34","tags":["typing","stubs","type hints","enum","python2","backport"],"install":[{"cmd":"pip install types-enum34","lang":"bash","label":"Install types-enum34"},{"cmd":"pip install enum34","lang":"bash","label":"Install enum34 (runtime library)"}],"dependencies":[{"reason":"This package provides typing stubs for the 'enum34' runtime library. It is only useful if 'enum34' (or an equivalent 'enum' backport) is installed and used in your project, typically for Python versions prior to 3.4.","package":"enum34","optional":false}],"imports":[{"symbol":"Enum","correct":"from enum import Enum"}],"quickstart":{"code":"from enum import Enum\nfrom typing import TYPE_CHECKING\n\n# This example demonstrates usage of enum34 (type-checked by types-enum34)\n# Ensure 'enum34' is installed in your Python 2.x or pre-3.4 environment.\n# For Python 3.4+, the 'enum' module is built-in.\n\nclass Color(Enum):\n    RED = 1\n    GREEN = 2\n    BLUE = 3\n\ndef get_color_name(color_enum: Color) -> str:\n    return color_enum.name\n\ndef get_color_value(color_enum: Color) -> int:\n    return color_enum.value\n\nif __name__ == '__main__':\n    my_color = Color.RED\n    print(f\"Selected color: {my_color}\")\n    print(f\"Name: {get_color_name(my_color)}\")\n    print(f\"Value: {get_color_value(my_color)}\")\n\n    # Example of type checking with mypy (assuming mypy is run externally)\n    # if TYPE_CHECKING:\n    #     reveal_type(my_color)\n    #     # The following would ideally be flagged by a type checker if `enum34` was in use and `types-enum34` enabled\n    #     # get_color_name('invalid_string') # type: ignore\n","lang":"python","description":"This quickstart demonstrates how to define and use an enumeration, consistent with the `enum34` library's API (which `types-enum34` provides stubs for). The `types-enum34` package itself does not introduce new runtime functionality; it merely provides static type hints. This code is designed to work with the `enum34` runtime package. For Python versions 3.4 and above, the `enum` module is part of the standard library, rendering `enum34` (and thus `types-enum34`) largely obsolete for new projects."},"warnings":[{"fix":"Do not install `enum34` on Python 3.4 or later. If it's already installed, uninstall it: `pip uninstall enum34`. Python 3.4+ includes `enum` in its standard library, making `enum34` redundant.","message":"Installing `enum34` (the runtime library for which `types-enum34` provides stubs) on Python 3.4 or newer environments can cause conflicts with the built-in `enum` module. This may lead to unexpected behavior, import issues, or break `pip` itself.","severity":"breaking","affected_versions":"Python 3.4+"},{"fix":"Ensure `enum34` is installed alongside `types-enum34` if you are targeting Python versions where `enum` is not part of the standard library (i.e., Python < 3.4).","message":"`types-enum34` is a stub package for static type checking. It does not provide the `enum` runtime functionality. You must install the `enum34` package separately (e.g., `pip install enum34`) for the code to run in Python environments older than 3.4.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For Python 3.4+, rely on the built-in `enum` module. If type checking is needed, mypy and other tools will automatically find stubs for the standard library module.","message":"The `enum` module became a part of the Python standard library in Python 3.4. The `enum34` backport (and consequently `types-enum34`) is primarily relevant for maintaining compatibility with Python 2.x and earlier Python 3.x versions. New projects targeting Python 3.4+ should use the built-in `enum` module directly and typically do not require `enum34` or `types-enum34`.","severity":"deprecated","affected_versions":"< 3.4 for runtime; primarily for Python 2.x usage with type checking."},{"fix":"Ensure you are using recent versions of your type checker and `types-enum34`. If issues persist, refer to the `typeshed` GitHub repository for the latest status and workarounds.","message":"There have been past issues with type checkers like MyPy correctly identifying `types-enum34` as Python 2 compatible when using `--py2` flags, or issues with metadata declarations in `typeshed` affecting stub compatibility.","severity":"gotcha","affected_versions":"Older MyPy versions (e.g., 0.910 with types-enum34 0.1.7)"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}