Sync from SUSE:SLFO:Main python-parso revision 5c4ff9b50c301e4a15730799014e8ce5

This commit is contained in:
Adrian Schröter 2024-05-03 21:47:15 +02:00
commit 40885fce7a
5 changed files with 450 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,181 @@
From cf5969d7a109798adbf9538d70e92138f077d700 Mon Sep 17 00:00:00 2001
From: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date: Sun, 4 Dec 2022 13:29:25 +0100
Subject: [PATCH] Fix unit tests in Python 3.10 (Closes: #192)
---
parso/python/errors.py | 51 ++++++++++++++++++++++++++++++--------
test/test_python_errors.py | 23 +++++++++++++++++
2 files changed, 64 insertions(+), 10 deletions(-)
diff --git a/parso/python/errors.py b/parso/python/errors.py
index 5da046a..09c5047 100644
--- a/parso/python/errors.py
+++ b/parso/python/errors.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import codecs
+import sys
import warnings
import re
from contextlib import contextmanager
@@ -33,7 +34,10 @@ def _get_rhs_name(node, version):
return "literal"
else:
if second.children[1] == ":" or second.children[0] == "**":
- return "dict display"
+ if version < (3, 10):
+ return "dict display"
+ else:
+ return "dict literal"
else:
return "set display"
elif (
@@ -47,7 +51,10 @@ def _get_rhs_name(node, version):
elif first == "[":
return "list"
elif first == "{" and second == "}":
- return "dict display"
+ if version < (3, 10):
+ return "dict display"
+ else:
+ return "dict literal"
elif first == "{" and len(node.children) > 2:
return "set display"
elif type_ == "keyword":
@@ -58,7 +65,10 @@ def _get_rhs_name(node, version):
else:
return str(node.value)
elif type_ == "operator" and node.value == "...":
- return "Ellipsis"
+ if version < (3, 10):
+ return "Ellipsis"
+ else:
+ return "ellipsis"
elif type_ == "comparison":
return "comparison"
elif type_ in ("string", "number", "strings"):
@@ -83,7 +93,10 @@ def _get_rhs_name(node, version):
or "_test" in type_
or type_ in ("term", "factor")
):
- return "operator"
+ if version < (3, 10):
+ return "operator"
+ else:
+ return "expression"
elif type_ == "star_expr":
return "starred"
elif type_ == "testlist_star_expr":
@@ -610,7 +623,10 @@ def is_issue(self, leaf):
@ErrorFinder.register_rule(type='string')
class _StringChecks(SyntaxRule):
- message = "bytes can only contain ASCII literal characters."
+ if sys.version_info < (3, 10):
+ message = "bytes can only contain ASCII literal characters."
+ else:
+ message = "bytes can only contain ASCII literal characters"
def is_issue(self, leaf):
string_prefix = leaf.string_prefix.lower()
@@ -1043,14 +1059,20 @@ def _check_assignment(self, node, is_deletion=False, is_namedexpr=False, is_aug_
error = 'literal'
else:
if second.children[1] == ':':
- error = 'dict display'
+ if self._normalizer.version < (3, 10):
+ error = 'dict display'
+ else:
+ error = 'dict literal'
else:
error = 'set display'
elif first == "{" and second == "}":
if self._normalizer.version < (3, 8):
error = 'literal'
else:
- error = "dict display"
+ if self._normalizer.version < (3, 10):
+ error = "dict display"
+ else:
+ error = "dict literal"
elif first == "{" and len(node.children) > 2:
if self._normalizer.version < (3, 8):
error = 'literal'
@@ -1083,7 +1105,10 @@ def _check_assignment(self, node, is_deletion=False, is_namedexpr=False, is_aug_
error = str(node.value)
elif type_ == 'operator':
if node.value == '...':
- error = 'Ellipsis'
+ if self._normalizer.version < (3, 10):
+ error = 'Ellipsis'
+ else:
+ error = 'ellipsis'
elif type_ == 'comparison':
error = 'comparison'
elif type_ in ('string', 'number', 'strings'):
@@ -1098,7 +1123,10 @@ def _check_assignment(self, node, is_deletion=False, is_namedexpr=False, is_aug_
if node.children[0] == 'await':
error = 'await expression'
elif node.children[-2] == '**':
- error = 'operator'
+ if self._normalizer.version < (3, 10):
+ error = 'operator'
+ else:
+ error = 'expression'
else:
# Has a trailer
trailer = node.children[-1]
@@ -1120,7 +1148,10 @@ def _check_assignment(self, node, is_deletion=False, is_namedexpr=False, is_aug_
elif ('expr' in type_ and type_ != 'star_expr' # is a substring
or '_test' in type_
or type_ in ('term', 'factor')):
- error = 'operator'
+ if self._normalizer.version < (3, 10):
+ error = 'operator'
+ else:
+ error = 'expression'
elif type_ == "star_expr":
if is_deletion:
if self._normalizer.version >= (3, 9):
diff --git a/test/test_python_errors.py b/test/test_python_errors.py
index adf5f06..9686d14 100644
--- a/test/test_python_errors.py
+++ b/test/test_python_errors.py
@@ -1,6 +1,7 @@
"""
Testing if parso finds syntax errors and indentation errors.
"""
+import re
import sys
import warnings
@@ -136,6 +137,28 @@ def _get_actual_exception(code):
wanted = 'SyntaxError: invalid syntax'
elif wanted == "SyntaxError: f-string: single '}' is not allowed":
wanted = 'SyntaxError: invalid syntax'
+ elif "Maybe you meant '==' instead of '='?" in wanted:
+ wanted = wanted.removesuffix(" here. Maybe you meant '==' instead of '='?")
+ elif re.match(
+ r"SyntaxError: unterminated string literal \(detected at line \d+\)", wanted
+ ):
+ wanted = "SyntaxError: EOL while scanning string literal"
+ elif re.match(
+ r"SyntaxError: unterminated triple-quoted string literal \(detected at line \d+\)",
+ wanted,
+ ):
+ wanted = 'SyntaxError: EOF while scanning triple-quoted string literal'
+ elif wanted == 'SyntaxError: cannot use starred expression here':
+ wanted = "SyntaxError: can't use starred expression here"
+ elif wanted == 'SyntaxError: f-string: cannot use starred expression here':
+ wanted = "SyntaxError: f-string: can't use starred expression here"
+ elif re.match(
+ r"IndentationError: expected an indented block after '[^']*' statement on line \d",
+ wanted,
+ ):
+ wanted = 'IndentationError: expected an indented block'
+ elif wanted == 'SyntaxError: unterminated string literal':
+ wanted = 'SyntaxError: EOL while scanning string literal'
return [wanted], line_nr

BIN
parso-0.8.3.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

173
python-parso.changes Normal file
View File

@ -0,0 +1,173 @@
-------------------------------------------------------------------
Fri Apr 21 12:29:02 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Thu Apr 13 22:42:54 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Make calling of %{sle15modernpython} optional.
-------------------------------------------------------------------
Fri Jan 6 21:44:16 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add cf5969d7a109798adbf9538d70e92138f077d700.patch to fix
unit tests with Python 3.11/3.12
-------------------------------------------------------------------
Fri Dec 10 20:32:47 UTC 2021 - Ben Greiner <code@bnavigator.de>
- update to 0.8.3:
* Add basic support for Python 3.11 and 3.12
- Skip tests failing in Python 3.10 gh#davidhalter/parso#192
-------------------------------------------------------------------
Sun Jun 6 12:41:51 UTC 2021 - Dirk Müller <dmueller@suse.com>
- update to 0.8.2:
- Various small bugfixes
-------------------------------------------------------------------
Fri Dec 25 19:00:15 UTC 2020 - Matej Cepl <mcepl@suse.com>
- update to 0.8.1 (according to gh#davidhalter/jedi#1650 it
should be compatible with python-jedi now):
- 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
-------------------------------------------------------------------
Sat Dec 19 13:16:55 UTC 2020 - Dirk Müller <dmueller@suse.com>
- update to 0.7.1:
- Fixed a couple of smaller bugs (mostly syntax error detection in
``Grammar.iter_errors``)
-------------------------------------------------------------------
Thu Sep 3 20:25:27 UTC 2020 - Matej Cepl <mcepl@suse.com>
- Revert back to the 0.7.0 version.
-------------------------------------------------------------------
Tue Apr 14 10:03:43 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- update to 0.7.0
* 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.
- remove py_38.patch (merged upstream)
-------------------------------------------------------------------
Thu Mar 5 12:25:09 UTC 2020 - Ondřej Súkup <mimi.vx@gmail.com>
- update to 0.6.2
* Add Grammar.refactor (might still be subject to change until 0.7.0)
* add py_38.patch - fix tests with py-3.8.2
-------------------------------------------------------------------
Tue Feb 4 09:32:19 UTC 2020 - Ondřej Súkup <mimi.vx@gmail.com>
- update to 0.6.1
* Add parso.normalizer.Issue.end_pos to make it possible to know
where an issue ends
* Dropped Python 2.6/Python 3.3 support
* del_stmt names are now considered as a definition (for name.is_definition())
-------------------------------------------------------------------
Fri Dec 27 17:14:25 UTC 2019 - Ondřej Súkup <mimi.vx@gmail.com>
- update to 0.5.2
* Add include_setitem to get_definition/is_definition and get_defined_names
* Fix named expression error listing
* Fix some f-string tokenizer issues
-------------------------------------------------------------------
Tue Jul 16 10:37:44 UTC 2019 - Ondřej Súkup <mimi.vx@gmail.com>
- update to 0.5.1
* Fix: Some unicode identifiers were not correctly tokenized
* Fix: Line continuations in f-strings are now working
-------------------------------------------------------------------
Tue Jul 2 09:42:44 UTC 2019 - Marketa Calabkova <mcalabkova@suse.com>
- update to 0.5.0
* 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
-------------------------------------------------------------------
Thu Apr 18 12:40:50 UTC 2019 - Ondřej Súkup <mimi.vx@gmail.com>
- update to 0.4.0
* Python 3.8 support
* FileIO support, it's now possible to use abstract file IO, support is alpha
-------------------------------------------------------------------
Thu Feb 14 12:10:20 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 0.3.4:
* Fix an f-string tokenizer error
* Fix async errors in the diff parser
* A fix in iter_errors
* 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
-------------------------------------------------------------------
Thu Feb 14 12:09:39 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Drop bogus dependency on pytest-cache
-------------------------------------------------------------------
Tue Dec 4 12:51:12 UTC 2018 - Matej Cepl <mcepl@suse.com>
- Remove superfluous devel dependency for noarch package
-------------------------------------------------------------------
Tue Jul 17 13:15:39 UTC 2018 - tchvatal@suse.com
- Drop dependency on tox, not really needed
-------------------------------------------------------------------
Thu Jul 12 15:55:46 UTC 2018 - arun@gmx.de
- specfile:
* make sure tests are run
- update to version 0.3.1:
* Bugfixes in the diff parser and keyword-only arguments
-------------------------------------------------------------------
Mon Jul 2 01:14:00 UTC 2018 - arun@gmx.de
- update to version 0.3.0:
* Rewrote the pgen2 parser generator.
-------------------------------------------------------------------
Tue Apr 17 01:53:46 UTC 2018 - arun@gmx.de
- specfile:
* update copyright year
- update to version 0.2.0:
* f-strings are now parsed as a part of the normal Python
grammar. This makes it way easier to deal with them.
-------------------------------------------------------------------
Thu Nov 9 06:12:31 UTC 2017 - arun@gmx.de
- update to version 0.1.1:
* Fixed a few bugs in the caching layer
* Added support for Python 3.7
-------------------------------------------------------------------
Tue Sep 26 05:37:33 UTC 2017 - arun@gmx.de
- intial version 0.1.0

70
python-parso.spec Normal file
View File

@ -0,0 +1,70 @@
#
# spec file for package python-parso
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
%{?sle15_python_module_pythons}
Name: python-parso
Version: 0.8.3
Release: 0
Summary: An autocompletion tool for Python
License: MIT AND Python-2.0
URL: https://github.com/davidhalter/parso
Source0: https://files.pythonhosted.org/packages/source/p/parso/parso-%{version}.tar.gz
Patch1: https://github.com/davidhalter/parso/commit/cf5969d7a109798adbf9538d70e92138f077d700.patch
BuildRequires: %{python_module pytest >= 3.0.7}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
%python_subpackages
%description
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.
%prep
%autosetup -p1 -n parso-%{version}
%build
%python_build
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# Python 3.10 has deviating exception messages -- gh#davidhalter/parso#192
python310_args=("-k" "not test_python_exception_matches")
%pytest "${$python_args[@]}"
%files %{python_files}
%license LICENSE.txt
%doc AUTHORS.txt CHANGELOG.rst README.rst
%{python_sitelib}/parso-%{version}-py*.egg-info
%{python_sitelib}/parso/
%changelog