Install & Compatibility
Where this runs
tested against v0.6.6 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.026s · 18.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.026s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TypeBuilder
✓ from parse_type import TypeBuilder
✗ from parse_type.parse import TypeBuilder
TypeBuilder is the main entry point for creating custom types, not directly from the embedded 'parse' module.
parse
✓ from parse import parse
✗ import parse_type.parse
While parse-type embeds its own parse module, the standard way to import the parse function is from the top-level 'parse' package. If parse-type is your only parse provider, this will typically resolve to its embedded version.
This quickstart demonstrates how to define a custom type using an Enum and integrate it into a `parse` pattern. It uses `TypeBuilder.with_enum` to prepare the custom type, then passes it to the `parse` function.
from enum import Enum
from parse import parse
from parse_type import TypeBuilder
# 1. Define an Enum to be used as a custom type
class ColorEnum(Enum):
red = 1
green = 2
blue = 3
# 2. Create a TypeBuilder instance, integrating the Enum
# TypeBuilder can also create types from regex or functions.
parse_types = TypeBuilder.with_enum(ColorEnum)
# 3. Define a parse pattern using the custom type
pattern = "The color is {color:Color}"
text = "The color is blue"
# 4. Use the parse function, passing the custom type definitions
# The key 'Color' in the dict corresponds to the type name in the pattern.
result = parse(pattern, text, dict(Color=parse_types.Color))
if result:
print(f"Successfully parsed! Color: {result['color']}")
print(f"Type of parsed color: {type(result['color'])}")
assert result['color'] is ColorEnum.blue
print("Assertion successful: Parsed value matches Enum member.")
else:
print("Parsing failed.")
Debug
Known issues
gotchaThe `parse-type` library embeds its own copy of the `parse` module (e.g., `parse_type.parse`). This can lead to confusion or potential version conflicts if you also have the `parse` library installed externally from PyPI. While `parse-type` aims for compatibility, explicit imports of `parse` might pick up the external version instead of the embedded one.fixBe aware that `parse-type` internally manages its `parse` dependency. It's generally safest to rely on `parse-type`'s embedded version or explicitly import `parse_type.parse` if you need to guarantee which `parse` implementation you are using in specific scenarios. Keep `parse-type` updated to get the latest compatible `parse` module behavior.
affects: All versions
deprecatedAlthough `parse-type` specifies Python 2.7 support in its `requires_python` metadata, Python 2.7 is end-of-life and no longer receives security updates. Using `parse-type` with Python 2.7 is strongly discouraged.fixEnsure you are using `parse-type` with a modern, actively supported version of Python 3 (e.g., Python 3.8+).
affects: All versions supporting Python 2.7
gotchaReleases of `parse-type` have included fixes related to upstream behavior changes in the `parse` module (e.g., `parse v1.19.1` breaking some behavior). This highlights that the interaction with `parse` can be subtle.fixAlways use the latest stable version of `parse-type` to ensure you benefit from the most up-to-date and stable `parse` module behavior that the library bundles and is tested against.
affects: <0.6.3
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'parse'
The Python 'parse' library (which 'parse-type' extends) is not installed or cannot be found in the current Python environment.
fixEnsure the 'parse' library is installed using pip: `pip install parse` or `pip3 install parse`.
AttributeError: 'module' object has no attribute 'parse'
This typically occurs when a user has a local file or another installed package named 'parse.py' that shadows the actual 'parse' library, or if they are trying to access a 'parse' method on an object that isn't the module itself.
fixRename any local 'parse.py' files to avoid conflicts, or ensure you are correctly importing and using the 'parse' module (e.g., `import parse` then `parse.parse(...)`).
ValueError: invalid literal for int() with base 10: 'some_string'
A custom type definition, particularly one using `parse_type.cfn` for integer conversion or a similar transformation, received input that could not be converted into an integer.
fixEnsure the input string matches the expected format for the custom type's conversion function. If using `int`, the input string must represent a valid integer.
re.error: missing ), unterminated subpattern at position X
A regular expression pattern provided to `parse_type.regex` is syntactically incorrect, leading to an error in Python's underlying `re` module.
fixCorrect the syntax of the regular expression pattern used in your `parse_type.regex` definition to ensure it is valid.
Upgrade
Version history
0.6.6latest on PyPI · released Aug 11, 2025
Audit
Dependencies
No dependency data recorded yet.