Registry / type-stubs / types-antlr4-python3-runtime

types-antlr4-python3-runtime

JSON →
library4.13.0.20260518pypypiunverified

This package provides static type checking stubs for the `antlr4-python3-runtime` library, enabling type checkers like MyPy and Pyright to analyze code that uses ANTLR 4's Python runtime. It is part of the `typeshed` project and aims to provide accurate annotations for `antlr4-python3-runtime==4.13.*`. Releases are frequent, often incorporating a date suffix, reflecting updates within the `typeshed` project and alignment with the underlying runtime.

pip install types-antlr4-python3-runtime
INSTALL
IMPORT
SIG · TYPES-ANTLR4-PYTHO
T
types-antlr4-python3-runtime
type-stubspythonv4.13.0.20260518
Install
1.6s avg
Import
35ms
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.13.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.940 runs
installs and imports cleanly · install 0.0s · import 0.038s · 66.6MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 1.6s · import 0.032s · 19MB
66MB installed
● package 66MB
Code
Verified usage

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

InputStream
from antlr4_stubs import InputStream
from antlr4 import InputStream

This quickstart demonstrates how to use the core `antlr4-python3-runtime` components with ANTLR-generated lexer and parser classes. The `types-antlr4-python3-runtime` package provides type hints for all `antlr4` imports and the expected interfaces of generated classes, improving developer experience with static analysis tools. Note that the ANTLR tool (a Java JAR) is required separately to generate `MyGrammarLexer.py` and `MyGrammarParser.py` from your `.g4` grammar file.

import os from antlr4 import InputStream, CommonTokenStream, ParseTreeWalker # --- Example: Assumes MyGrammar.g4 was compiled to MyGrammarLexer.py and MyGrammarParser.py --- # To generate these files, you need the ANTLR Java tool (antlr-VERSION-complete.jar): # java -jar /path/to/antlr-VERSION-complete.jar MyGrammar.g4 -Dlanguage=Python3 # Placeholder for generated classes (replace with actual generated imports) # For a real scenario, these would be in files like MyGrammarLexer.py and MyGrammarParser.py class MyGrammarLexer: def __init__(self, input_stream): pass # Simplified for quickstart def getAllTokens(self): return [] # Simplified class MyGrammarParser: def __init__(self, token_stream): pass # Simplified def myRule(self): class Context: def accept(self, visitor): pass def toStringTree(self, recog=None): return "(myRule)" return Context() # Simplified class MyGrammarListener: def enterMyRule(self, ctx): pass def exitMyRule(self, ctx): pass # Example usage of the antlr4-python3-runtime with generated classes input_text = "hello world" input_stream = InputStream(input_text) lexer = MyGrammarLexer(input_stream) token_stream = CommonTokenStream(lexer) parser = MyGrammarParser(token_stream) # Assume 'myRule' is the entry point for your grammar tree = parser.myRule() print(f"Parsed tree: {tree.toStringTree(recog=parser)}") # Using a listener for tree traversal listener = MyGrammarListener() walker = ParseTreeWalker() walker.walk(listener, tree) print("Type checking enabled for antlr4 classes by types-antlr4-python3-runtime.")
Debug
Known issues
breakingThe `antlr4-python3-runtime` library, which these stubs target, has known incompatibilities with specific Python versions. Notably, `antlr4-python3-runtime==4.11.1` is incompatible with Python 3.13+ due to changes in CPython's internal APIs. Users of Python 3.13 or newer should ensure they are using `antlr4-python3-runtime>=4.13.0`. Always check the compatibility matrix for the underlying runtime.
fix
Upgrade `antlr4-python3-runtime` to version `4.13.0` or newer when using Python 3.13+.
affects: antlr4-python3-runtime < 4.13.0 for Python >= 3.13
gotchaThis package provides *only* type stubs. It does not include the actual `antlr4-python3-runtime` library. For your code to run, you must install `antlr4-python3-runtime` separately. Additionally, the ANTLR parser generator tool itself (which converts `.g4` grammars to Python source files) requires a Java Runtime Environment (JRE) to operate, which can be a point of confusion for Python-only developers.
fix
Ensure both `types-antlr4-python3-runtime` and `antlr4-python3-runtime` are installed. If generating parsers, ensure Java is installed and the ANTLR `.jar` tool is available.
affects: All versions
gotchaAs a type stub package part of the `typeshed` project, fixes or improvements to the type annotations should be contributed directly to the `typeshed` GitHub repository, not to this `types-` package directly.
fix
Report type-related issues or propose changes to the `antlr4-python3-runtime` stub in the main `typeshed` repository on GitHub.
affects: All versions
Upgrade
Version history
4.13.0.20260518latest on PyPI · released May 18, 2026
Audit
Dependencies
antlr4-python3-runtimerequiredThis package provides type stubs for the 'antlr4-python3-runtime' library; the actual runtime must be installed to execute code.
pythonrequiredRequires Python 3.10 or newer.
Agent activity
31 hits · last 30 days
node
26
OpenAI (training)
2
Resources
types-antlr4-python3-runtime — pip install types-antlr4-python3-runtime · libregistry