Skip to main content
Travis-CI build status Coverage Status https://raw.githubusercontent.com/davidhalter/parso/master/docs/_static/logo_characters.png

Parso is a Python parser that supports error recovery and round-trip parsing for different Python versions (in multiple Python versions). Parso is also able to list multiple syntax errors in your python file.

Parso has been battle-tested by jedi. It was pulled out of jedi to be useful for other projects as well.

Parso consists of a small API to parse Python and analyse the syntax tree.

A simple example:

>>> import parso
>>> module = parso.parse('hello + 1', version="3.6")
>>> expr = module.children[0]
>>> expr
PythonNode(arith_expr, [<Name: hello@1,0>, <Operator: +>, <Number: 1>])
>>> print(expr.get_code())
hello + 1
>>> name = expr.children[0]
>>> name
<Name: hello@1,0>
>>> name.end_pos
(1, 5)
>>> expr.end_pos
(1, 9)

To list multiple issues:

>>> grammar = parso.load_grammar()
>>> module = grammar.parse('foo +\nbar\ncontinue')
>>> error1, error2 = grammar.iter_errors(module)
>>> error1.message
'SyntaxError: invalid syntax'
>>> error2.message
"SyntaxError: 'continue' not properly in loop"

Resources

Installation

pip install parso

Future

  • There will be better support for refactoring and comments. Stay tuned.

  • There’s a WIP PEP8 validator. It’s however not in a good shape, yet.

Known Issues

  • async/await are already used as keywords in Python3.6.

  • from __future__ import print_function is not ignored.

Acknowledgements

  • Guido van Rossum (@gvanrossum) for creating the parser generator pgen2 (originally used in lib2to3).

  • Salome Schneider for the extremely awesome parso logo.

Changelog

0.1.1 (2017-11-05)

  • Fixed a few bugs in the caching layer

  • Added support for Python 3.7

0.1.0 (2017-09-04)

  • Pulling the library out of Jedi. Some APIs will definitely change.

Metadata

Release files for parso 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parso 0.1.1
File Size Uploaded
parso-0.1.1.tar.gz 379.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for parso 0.1.1
File Interpreter ABI Platform
parso-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 471.4 kB

Release files / parso-0.1.1.tar.gz

Download URL parso-0.1.1.tar.gz
Size 379.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5815f3fe254e5665f3c5d6f54f086c2502035cb631a91341591b5a564203cffb
BLAKE2b-256 checksum
How to use checksums
143b15cfd9c7a8bd9e3a2fe956e20fbc4e7c5768e06aea347d8eb68a05a71653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / parso-0.1.1-py2.py3-none-any.whl

Download URL parso-0.1.1-py2.py3-none-any.whl
Size 92.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a7bb86fe0844304869d1c08e8bd0e52be931228483025c422917411ab82d628a
BLAKE2b-256 checksum
How to use checksums
c62f96f54499c920070ccc1bffaee115a6a0cf1a0e7ece34b8faa7ee632688dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page