{"id":448,"library":"parso","title":"Parso: A Python Parser","description":"Parso is a Python parser that supports error recovery and round-trip parsing for different Python versions. It is currently at version 0.8.6, released on February 9, 2026, and follows a regular release cadence with updates approximately every 6 months.","status":"active","version":"0.8.6","language":"python","source_language":"en","source_url":"https://github.com/davidhalter/parso","tags":["parsing","Python","syntax tree","error recovery","round-trip parsing"],"install":[{"cmd":"pip install parso","lang":"bash","label":"Install Parso"}],"dependencies":[{"reason":"Required for type annotations","package":"typing","optional":false}],"imports":[{"note":"The 'parse' function is the main entry point for parsing Python code.","symbol":"parse","correct":"from parso import parse"}],"quickstart":{"code":"import parso\n\ncode = 'def greet(name):\\n    return f\"Hello, {name}!\"\\n\\ngreet('World')'\n\n# Parse the code\nmodule = parso.parse(code, version='3.9')\n\n# Access the root node\nroot_node = module.get_root_node()\n\n# Print the parsed code\nprint(root_node.get_code())","lang":"python","description":"This example demonstrates how to parse a simple Python function definition and call using Parso."},"warnings":[{"fix":"Upgrade to a supported Python version (3.6 or later).","message":"Parso dropped support for Python 2.7, 3.4, and 3.5 in version 0.8.0.","severity":"breaking","affected_versions":"0.8.0"},{"fix":"Use Parso for parsing tasks instead of 'lib2to3'.","message":"The 'lib2to3' module is deprecated since Python 3.10 and may be removed in future versions. Parso is a recommended alternative.","severity":"deprecated","affected_versions":"3.10+"},{"fix":"To resolve, escape the internal single quotes (e.g., `\\'World\\'`) or enclose the entire string in double quotes (`\"...\"`) or triple quotes (`'''...'''`) to allow internal single quotes without escaping.","message":"A `SyntaxError: invalid syntax` occurred because a single-quoted string literal (`'...'`) contained an unescaped single quote, prematurely terminating the string and leading to invalid syntax at the subsequent characters.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure string literals in test scripts are correctly escaped (e.g., `\\'World\\'`) or use triple quotes (e.g., `'''... 'World' ...'''`) to define multi-line code snippets that contain single or double quotes.","message":"A `SyntaxError` occurred in the test script due to an unescaped quote within a string literal used for code generation, preventing the script from running. This is a fundamental Python syntax issue with string definition.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T13:52:59.480Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install the 'parso' package using pip: `pip install parso`","cause":"The 'parso' library has not been installed in the Python environment where the code is being executed.","error":"ModuleNotFoundError: No module named 'parso'"},{"fix":"Correct the syntax of the Python code being parsed. If the code uses modern Python features, ensure your installed 'parso' version is up-to-date (`pip install --upgrade parso`) and explicitly specify the Python version using the `version` parameter in `parso.parse()` or `parso.load_grammar()` (e.g., `parso.parse('code', version='3.9')`).","cause":"This error message is typically returned by `parso` when the code it attempts to parse contains actual Python syntax errors, or when `parso` is used with a Python version that doesn't match the syntax of the provided code.","error":"SyntaxError: invalid syntax"},{"fix":"Instead of directly importing `Parser`, use the public API functions like `parso.parse()` for simple parsing or `parso.load_grammar().parse()` for more controlled parsing with a specific grammar.","cause":"Users attempting to directly import a class named 'Parser' from the 'parso' package or its submodules, which is not part of the public API or has a different internal name.","error":"ImportError: cannot import name 'Parser'"},{"fix":"Review the string literal in the code for proper escaping of special characters like curly braces in f-strings or backslashes in raw strings. Ensure the string is well-formed according to Python's grammar. Updating 'parso' to the latest version might also resolve issues with newer string syntaxes.","cause":"This error can occur when `parso` encounters complex or malformed string literals, especially f-strings or raw strings with unescaped curly braces, that it struggles to tokenize or parse correctly.","error":"KeyError: ReservedString(})"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":5,"disk_size":"18.4M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":5,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.15,"mem_mb":4.8,"disk_size":"20.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":4.8,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":4.6,"disk_size":"12.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":4.6,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":4.6,"disk_size":"11.9M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":4.4,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":4.8,"disk_size":"17.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":4.8,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}