{"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,"search_vec":"'0.8.6':28 '2026':33 '6':44 '9':32 'approxim':42 'cadenc':39 'current':25 'differ':20 'error':12,50 'everi':43 'februari':31 'follow':35 'month':45 'pars':18,46,55 'parser':4,9 'parso':1,5 'python':3,8,21,47 'recoveri':13,51 'regular':37 'releas':29,38 'round':16,53 'round-trip':15,52 'support':11 'syntax':48 'tree':49 'trip':17,54 'updat':41 'version':22,27","created_at":"2026-03-28T12:03:01.754697+00:00","updated_at":"2026-04-16T17:53:49.570617+00:00","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,"quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"0.8.7","cli_name":"","cli_version":null,"type":"library","homepage":"https://parso.readthedocs.io","github":"https://github.com/davidhalter/parso","docs":null,"changelog":null,"pypi":"https://pypi.org/project/parso/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}