###################################################################
parso - A Python Parser
###################################################################
.. image:: https://github.com/davidhalter/parso/workflows/Build/badge.svg?branch=master
:target: https://github.com/davidhalter/parso/actions
:alt: GitHub Actions build status
.. image:: https://coveralls.io/repos/github/davidhalter/parso/badge.svg?branch=master
:target: https://coveralls.io/github/davidhalter/parso?branch=master
:alt: Coverage Status
.. image:: https://pepy.tech/badge/parso
:target: https://pepy.tech/project/parso
:alt: PyPI Downloads
.. image:: 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:
.. code-block:: python
>>> import parso
>>> module = parso.parse('hello + 1', version="3.9")
>>> 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:
.. code-block:: python
>>> 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
=========
- `Testing <https://parso.readthedocs.io/en/latest/docs/development.html#testing>`_
- `PyPI <https://pypi.python.org/pypi/parso>`_
- `Docs <https://parso.readthedocs.org/en/latest/>`_
- Uses `semantic versioning <https://semver.org/>`_
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 <https://www.crepes-schnaegg.ch/cr%C3%AApes-schn%C3%A4gg/kunst-f%C3%BCrs-cr%C3%AApes-mobil/>`_
for the extremely awesome parso logo.
.. _jedi: https://github.com/davidhalter/jedi
.. :changelog:
Changelog
---------
Unreleased
++++++++++
0.8.4 (2024-04-05)
++++++++++++++++++
- Add basic support for Python 3.13
0.8.3 (2021-11-30)
++++++++++++++++++
- Add basic support for Python 3.11 and 3.12
0.8.2 (2021-03-30)
++++++++++++++++++
- Various small bugfixes
0.8.1 (2020-12-10)
++++++++++++++++++
- Various small bugfixes
0.8.0 (2020-08-05)
++++++++++++++++++
- Dropped Support for Python 2.7, 3.4, 3.5
- It's possible to use ``pathlib.Path`` objects now in the API
- The stubs are gone, we are now using annotations
- ``namedexpr_test`` nodes are now a proper class called ``NamedExpr``
- A lot of smaller refactorings
0.7.1 (2020-07-24)
++++++++++++++++++
- Fixed a couple of smaller bugs (mostly syntax error detection in
``Grammar.iter_errors``)
This is going to be the last release that supports Python 2.7, 3.4 and 3.5.
0.7.0 (2020-04-13)
++++++++++++++++++
- Fix a lot of annoying bugs in the diff parser. The fuzzer did not find
issues anymore even after running it for more than 24 hours (500k tests).
- Small grammar change: suites can now contain newlines even after a newline.
This should really not matter if you don't use error recovery. It allows for
nicer error recovery.
0.6.2 (2020-02-27)
++++++++++++++++++
- Bugfixes
- Add Grammar.refactor (might still be subject to change until 0.7.0)
0.6.1 (2020-02-03)
++++++++++++++++++
- Add ``parso.normalizer.Issue.end_pos`` to make it possible to know where an
issue ends
0.6.0 (2020-01-26)
++++++++++++++++++
- Dropped Python 2.6/Python 3.3 support
- del_stmt names are now considered as a definition
(for ``name.is_definition()``)
- Bugfixes
0.5.2 (2019-12-15)
++++++++++++++++++
- Add include_setitem to get_definition/is_definition and get_defined_names (#66)
- Fix named expression error listing (#89, #90)
- Fix some f-string tokenizer issues (#93)
0.5.1 (2019-07-13)
++++++++++++++++++
- Fix: Some unicode identifiers were not correctly tokenized
- Fix: Line continuations in f-strings are now working
0.5.0 (2019-06-20)
++++++++++++++++++
- **Breaking Change** comp_for is now called sync_comp_for for all Python
versions to be compatible with the Python 3.8 Grammar
- Added .pyi stubs for a lot of the parso API
- Small FileIO changes
0.4.0 (2019-04-05)
++++++++++++++++++
- Python 3.8 support
- FileIO support, it's now possible to use abstract file IO, support is alpha
0.3.4 (2019-02-13)
+++++++++++++++++++
- Fix an f-string tokenizer error
0.3.3 (2019-02-06)
+++++++++++++++++++
- Fix async errors in the diff parser
- A fix in iter_errors
- This is a very small bugfix release
0.3.2 (2019-01-24)
+++++++++++++++++++
- 20+ bugfixes in the diff parser and 3 in the tokenizer
- A fuzzer for the diff parser, to give confidence that the diff parser is in a
good shape.
- Some bugfixes for f-string
0.3.1 (2018-07-09)
+++++++++++++++++++
- Bugfixes in the diff parser and keyword-only arguments
0.3.0 (2018-06-30)
+++++++++++++++++++
- Rewrote the pgen2 parser generator.
0.2.1 (2018-05-21)
+++++++++++++++++++
- A bugfix for the diff parser.
- Grammar files can now be loaded from a specific path.
0.2.0 (2018-04-15)
+++++++++++++++++++
- f-strings are now parsed as a part of the normal Python grammar. This makes
it way easier to deal with them.
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/davidhalter/parso",
"name": "parso",
"maintainer": "David Halter",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "davidhalter88@gmail.com",
"keywords": "python parser parsing",
"author": "David Halter",
"author_email": "davidhalter88@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/66/94/68e2e17afaa9169cf6412ab0f28623903be73d1b32e208d9e8e541bb086d/parso-0.8.4.tar.gz",
"platform": "any",
"description": "###################################################################\nparso - A Python Parser\n###################################################################\n\n\n.. image:: https://github.com/davidhalter/parso/workflows/Build/badge.svg?branch=master\n :target: https://github.com/davidhalter/parso/actions\n :alt: GitHub Actions build status\n\n.. image:: https://coveralls.io/repos/github/davidhalter/parso/badge.svg?branch=master\n :target: https://coveralls.io/github/davidhalter/parso?branch=master\n :alt: Coverage Status\n\n.. image:: https://pepy.tech/badge/parso\n :target: https://pepy.tech/project/parso\n :alt: PyPI Downloads\n\n.. image:: https://raw.githubusercontent.com/davidhalter/parso/master/docs/_static/logo_characters.png\n\nParso is a Python parser that supports error recovery and round-trip parsing\nfor different Python versions (in multiple Python versions). Parso is also able\nto list multiple syntax errors in your python file.\n\nParso has been battle-tested by jedi_. It was pulled out of jedi to be useful\nfor other projects as well.\n\nParso consists of a small API to parse Python and analyse the syntax tree.\n\nA simple example:\n\n.. code-block:: python\n\n >>> import parso\n >>> module = parso.parse('hello + 1', version=\"3.9\")\n >>> expr = module.children[0]\n >>> expr\n PythonNode(arith_expr, [<Name: hello@1,0>, <Operator: +>, <Number: 1>])\n >>> print(expr.get_code())\n hello + 1\n >>> name = expr.children[0]\n >>> name\n <Name: hello@1,0>\n >>> name.end_pos\n (1, 5)\n >>> expr.end_pos\n (1, 9)\n\nTo list multiple issues:\n\n.. code-block:: python\n\n >>> grammar = parso.load_grammar()\n >>> module = grammar.parse('foo +\\nbar\\ncontinue')\n >>> error1, error2 = grammar.iter_errors(module)\n >>> error1.message\n 'SyntaxError: invalid syntax'\n >>> error2.message\n \"SyntaxError: 'continue' not properly in loop\"\n\nResources\n=========\n\n- `Testing <https://parso.readthedocs.io/en/latest/docs/development.html#testing>`_\n- `PyPI <https://pypi.python.org/pypi/parso>`_\n- `Docs <https://parso.readthedocs.org/en/latest/>`_\n- Uses `semantic versioning <https://semver.org/>`_\n\nInstallation\n============\n\n pip install parso\n\nFuture\n======\n\n- There will be better support for refactoring and comments. Stay tuned.\n- There's a WIP PEP8 validator. It's however not in a good shape, yet.\n\nKnown Issues\n============\n\n- `async`/`await` are already used as keywords in Python3.6.\n- `from __future__ import print_function` is not ignored.\n\n\nAcknowledgements\n================\n\n- Guido van Rossum (@gvanrossum) for creating the parser generator pgen2\n (originally used in lib2to3).\n- `Salome Schneider <https://www.crepes-schnaegg.ch/cr%C3%AApes-schn%C3%A4gg/kunst-f%C3%BCrs-cr%C3%AApes-mobil/>`_\n for the extremely awesome parso logo.\n\n\n.. _jedi: https://github.com/davidhalter/jedi\n\n\n.. :changelog:\n\nChangelog\n---------\n\nUnreleased\n++++++++++\n\n0.8.4 (2024-04-05)\n++++++++++++++++++\n\n- Add basic support for Python 3.13\n\n0.8.3 (2021-11-30)\n++++++++++++++++++\n\n- Add basic support for Python 3.11 and 3.12\n\n0.8.2 (2021-03-30)\n++++++++++++++++++\n\n- Various small bugfixes\n\n0.8.1 (2020-12-10)\n++++++++++++++++++\n\n- Various small bugfixes\n\n0.8.0 (2020-08-05)\n++++++++++++++++++\n\n- Dropped Support for Python 2.7, 3.4, 3.5\n- It's possible to use ``pathlib.Path`` objects now in the API\n- The stubs are gone, we are now using annotations\n- ``namedexpr_test`` nodes are now a proper class called ``NamedExpr``\n- A lot of smaller refactorings\n\n0.7.1 (2020-07-24)\n++++++++++++++++++\n\n- Fixed a couple of smaller bugs (mostly syntax error detection in\n ``Grammar.iter_errors``)\n\nThis is going to be the last release that supports Python 2.7, 3.4 and 3.5.\n\n0.7.0 (2020-04-13)\n++++++++++++++++++\n\n- Fix a lot of annoying bugs in the diff parser. The fuzzer did not find\n issues anymore even after running it for more than 24 hours (500k tests).\n- Small grammar change: suites can now contain newlines even after a newline.\n This should really not matter if you don't use error recovery. It allows for\n nicer error recovery.\n\n0.6.2 (2020-02-27)\n++++++++++++++++++\n\n- Bugfixes\n- Add Grammar.refactor (might still be subject to change until 0.7.0)\n\n0.6.1 (2020-02-03)\n++++++++++++++++++\n\n- Add ``parso.normalizer.Issue.end_pos`` to make it possible to know where an\n issue ends\n\n0.6.0 (2020-01-26)\n++++++++++++++++++\n\n- Dropped Python 2.6/Python 3.3 support\n- del_stmt names are now considered as a definition\n (for ``name.is_definition()``)\n- Bugfixes\n\n0.5.2 (2019-12-15)\n++++++++++++++++++\n\n- Add include_setitem to get_definition/is_definition and get_defined_names (#66)\n- Fix named expression error listing (#89, #90)\n- Fix some f-string tokenizer issues (#93)\n\n0.5.1 (2019-07-13)\n++++++++++++++++++\n\n- Fix: Some unicode identifiers were not correctly tokenized\n- Fix: Line continuations in f-strings are now working\n\n0.5.0 (2019-06-20)\n++++++++++++++++++\n\n- **Breaking Change** comp_for is now called sync_comp_for for all Python\n versions to be compatible with the Python 3.8 Grammar\n- Added .pyi stubs for a lot of the parso API\n- Small FileIO changes\n\n0.4.0 (2019-04-05)\n++++++++++++++++++\n\n- Python 3.8 support\n- FileIO support, it's now possible to use abstract file IO, support is alpha\n\n0.3.4 (2019-02-13)\n+++++++++++++++++++\n\n- Fix an f-string tokenizer error\n\n0.3.3 (2019-02-06)\n+++++++++++++++++++\n\n- Fix async errors in the diff parser\n- A fix in iter_errors\n- This is a very small bugfix release\n\n0.3.2 (2019-01-24)\n+++++++++++++++++++\n\n- 20+ bugfixes in the diff parser and 3 in the tokenizer\n- A fuzzer for the diff parser, to give confidence that the diff parser is in a\n good shape.\n- Some bugfixes for f-string\n\n0.3.1 (2018-07-09)\n+++++++++++++++++++\n\n- Bugfixes in the diff parser and keyword-only arguments\n\n0.3.0 (2018-06-30)\n+++++++++++++++++++\n\n- Rewrote the pgen2 parser generator.\n\n0.2.1 (2018-05-21)\n+++++++++++++++++++\n\n- A bugfix for the diff parser.\n- Grammar files can now be loaded from a specific path.\n\n0.2.0 (2018-04-15)\n+++++++++++++++++++\n\n- f-strings are now parsed as a part of the normal Python grammar. This makes\n it way easier to deal with them.\n\n0.1.1 (2017-11-05)\n+++++++++++++++++++\n\n- Fixed a few bugs in the caching layer\n- Added support for Python 3.7\n\n0.1.0 (2017-09-04)\n+++++++++++++++++++\n\n- Pulling the library out of Jedi. Some APIs will definitely change.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python Parser",
"version": "0.8.4",
"project_urls": {
"Homepage": "https://github.com/davidhalter/parso"
},
"split_keywords": [
"python",
"parser",
"parsing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c6acdac4a63f978e4dcb3c6d3a78c4d8e0192a113d288502a1216950c41b1027",
"md5": "ecc7f583a2cfc431b3686eaa1842ba22",
"sha256": "a418670a20291dacd2dddc80c377c5c3791378ee1e8d12bffc35420643d43f18"
},
"downloads": -1,
"filename": "parso-0.8.4-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "ecc7f583a2cfc431b3686eaa1842ba22",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6",
"size": 103650,
"upload_time": "2024-04-05T09:43:53",
"upload_time_iso_8601": "2024-04-05T09:43:53.299362Z",
"url": "https://files.pythonhosted.org/packages/c6/ac/dac4a63f978e4dcb3c6d3a78c4d8e0192a113d288502a1216950c41b1027/parso-0.8.4-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "669468e2e17afaa9169cf6412ab0f28623903be73d1b32e208d9e8e541bb086d",
"md5": "f83b2e4164f6589ccae39b16c30ed5de",
"sha256": "eb3a7b58240fb99099a345571deecc0f9540ea5f4dd2fe14c2a99d6b281ab92d"
},
"downloads": -1,
"filename": "parso-0.8.4.tar.gz",
"has_sig": false,
"md5_digest": "f83b2e4164f6589ccae39b16c30ed5de",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 400609,
"upload_time": "2024-04-05T09:43:55",
"upload_time_iso_8601": "2024-04-05T09:43:55.897427Z",
"url": "https://files.pythonhosted.org/packages/66/94/68e2e17afaa9169cf6412ab0f28623903be73d1b32e208d9e8e541bb086d/parso-0.8.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-05 09:43:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "davidhalter",
"github_project": "parso",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "parso"
}