Hello community, here is the log from the commit of package python-parso for openSUSE:Factory checked in at 2020-02-06 13:19:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-parso (Old) and /work/SRC/openSUSE:Factory/.python-parso.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-parso" Thu Feb 6 13:19:20 2020 rev:11 rq:769905 version:0.6.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-parso/python-parso.changes 2019-12-29 15:49:26.587169274 +0100 +++ /work/SRC/openSUSE:Factory/.python-parso.new.26092/python-parso.changes 2020-02-06 13:19:20.892675857 +0100 @@ -1,0 +2,9 @@ +Tue Feb 4 09:32:19 UTC 2020 - Ondřej Súkup <[email protected]> + +- 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()) + +------------------------------------------------------------------- Old: ---- parso-0.5.2.tar.gz New: ---- parso-0.6.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-parso.spec ++++++ --- /var/tmp/diff_new_pack.SeDN3R/_old 2020-02-06 13:19:21.460676135 +0100 +++ /var/tmp/diff_new_pack.SeDN3R/_new 2020-02-06 13:19:21.464676137 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-parso # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-parso -Version: 0.5.2 +Version: 0.6.1 Release: 0 Summary: An autocompletion tool for Python License: MIT AND Python-2.0 ++++++ parso-0.5.2.tar.gz -> parso-0.6.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/AUTHORS.txt new/parso-0.6.1/AUTHORS.txt --- old/parso-0.5.2/AUTHORS.txt 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/AUTHORS.txt 2020-02-03 21:46:42.000000000 +0100 @@ -49,6 +49,7 @@ Daniel Fiterman (@dfit99) <[email protected]> Simon Ruggier (@sruggier) Élie Gouzien (@ElieGouzien) +Tim Gates (@timgates42) <[email protected]> Note: (@user) means a github user name. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/CHANGELOG.rst new/parso-0.6.1/CHANGELOG.rst --- old/parso-0.5.2/CHANGELOG.rst 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/CHANGELOG.rst 2020-02-03 21:46:42.000000000 +0100 @@ -3,6 +3,20 @@ Changelog --------- +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) ++++++++++++++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/PKG-INFO new/parso-0.6.1/PKG-INFO --- old/parso-0.5.2/PKG-INFO 2019-12-15 01:01:27.000000000 +0100 +++ new/parso-0.6.1/PKG-INFO 2020-02-03 22:05:10.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: parso -Version: 0.5.2 +Version: 0.6.1 Summary: A Python Parser Home-page: https://github.com/davidhalter/parso Author: David Halter @@ -106,6 +106,20 @@ Changelog --------- + 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) ++++++++++++++++++ @@ -194,10 +208,8 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 @@ -205,4 +217,5 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Text Editors :: Integrated Development Environments (IDE) Classifier: Topic :: Utilities +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* Provides-Extra: testing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/conftest.py new/parso-0.6.1/conftest.py --- old/parso-0.5.2/conftest.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/conftest.py 2020-02-03 21:46:42.000000000 +0100 @@ -13,8 +13,8 @@ collect_ignore = ["setup.py"] -VERSIONS_2 = '2.6', '2.7' -VERSIONS_3 = '3.3', '3.4', '3.5', '3.6', '3.7', '3.8' +VERSIONS_2 = '2.7', +VERSIONS_3 = '3.4', '3.5', '3.6', '3.7', '3.8' @pytest.fixture(scope='session') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/__init__.py new/parso-0.6.1/parso/__init__.py --- old/parso-0.5.2/parso/__init__.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/__init__.py 2020-02-03 21:46:42.000000000 +0100 @@ -43,7 +43,7 @@ from parso.utils import split_lines, python_bytes_to_unicode -__version__ = '0.5.2' +__version__ = '0.6.1' def parse(code=None, **kwargs): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/_compatibility.py new/parso-0.6.1/parso/_compatibility.py --- old/parso-0.5.2/parso/_compatibility.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/_compatibility.py 2020-02-03 21:46:42.000000000 +0100 @@ -1,14 +1,10 @@ """ -To ensure compatibility from Python ``2.6`` - ``3.3``, a module has been +To ensure compatibility from Python ``2.7`` - ``3.3``, a module has been created. Clearly there is huge need to use conforming syntax. """ import sys import platform -# Cannot use sys.version.major and minor names, because in Python 2.6 it's not -# a namedtuple. -py_version = int(str(sys.version_info[0]) + str(sys.version_info[1])) - # unicode function try: unicode = unicode @@ -39,7 +35,7 @@ have to cast back to a unicode (and we know that we always deal with valid unicode, because we check that in the beginning). """ - if py_version >= 30: + if sys.version_info.major >= 3: return str(string) if not isinstance(string, unicode): @@ -48,8 +44,10 @@ try: + # Python 2.7 FileNotFoundError = FileNotFoundError except NameError: + # Python 3.3+ FileNotFoundError = IOError @@ -65,39 +63,7 @@ else: return result - if py_version >= 30: + if sys.version_info.major >= 3: return func else: return wrapper - - -try: - from functools import total_ordering -except ImportError: - # Python 2.6 - def total_ordering(cls): - """Class decorator that fills in missing ordering methods""" - convert = { - '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)), - ('__le__', lambda self, other: self < other or self == other), - ('__ge__', lambda self, other: not self < other)], - '__le__': [('__ge__', lambda self, other: not self <= other or self == other), - ('__lt__', lambda self, other: self <= other and not self == other), - ('__gt__', lambda self, other: not self <= other)], - '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)), - ('__ge__', lambda self, other: self > other or self == other), - ('__le__', lambda self, other: not self > other)], - '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other), - ('__gt__', lambda self, other: self >= other and not self == other), - ('__lt__', lambda self, other: not self >= other)] - } - roots = set(dir(cls)) & set(convert) - if not roots: - raise ValueError('must define at least one ordering operation: < > <= >=') - root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__ - for opname, opfunc in convert[root]: - if opname not in roots: - opfunc.__name__ = opname - opfunc.__doc__ = getattr(int, opname).__doc__ - setattr(cls, opname, opfunc) - return cls diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/cache.py new/parso-0.6.1/parso/cache.py --- old/parso-0.5.2/parso/cache.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/cache.py 2020-02-03 21:46:42.000000000 +0100 @@ -17,8 +17,23 @@ LOG = logging.getLogger(__name__) +_CACHED_FILE_MINIMUM_SURVIVAL = 60 * 10 # 10 minutes +""" +Cached files should survive at least a few minutes. +""" +_CACHED_SIZE_TRIGGER = 600 +""" +This setting limits the amount of cached files. It's basically a way to start +garbage collection. -_PICKLE_VERSION = 32 +The reasoning for this limit being as big as it is, is the following: + +Numpy, Pandas, Matplotlib and Tensorflow together use about 500 files. This +makes Jedi use ~500mb of memory. Since we might want a bit more than those few +libraries, we just increase it a bit. +""" + +_PICKLE_VERSION = 33 """ Version number (integer) for file system cache. @@ -40,7 +55,7 @@ """ Short name for distinguish Python implementations and versions. -It's like `sys.implementation.cache_tag` but for Python < 3.3 +It's like `sys.implementation.cache_tag` but for Python2 we generate something similar. See: http://docs.python.org/3/library/sys.html#sys.implementation """ @@ -76,6 +91,7 @@ if change_time is None: change_time = time.time() self.change_time = change_time + self.last_used = change_time def load_module(hashed_grammar, file_io, cache_path=None): @@ -89,6 +105,7 @@ try: module_cache_item = parser_cache[hashed_grammar][file_io.path] if p_time <= module_cache_item.change_time: + module_cache_item.last_used = time.time() return module_cache_item.node except KeyError: return _load_from_file_system( @@ -122,11 +139,27 @@ except FileNotFoundError: return None else: - parser_cache.setdefault(hashed_grammar, {})[path] = module_cache_item + _set_cache_item(hashed_grammar, path, module_cache_item) LOG.debug('pickle loaded: %s', path) return module_cache_item.node +def _set_cache_item(hashed_grammar, path, module_cache_item): + if sum(len(v) for v in parser_cache.values()) >= _CACHED_SIZE_TRIGGER: + # Garbage collection of old cache files. + # We are basically throwing everything away that hasn't been accessed + # in 10 minutes. + cutoff_time = time.time() - _CACHED_FILE_MINIMUM_SURVIVAL + for key, path_to_item_map in parser_cache.items(): + parser_cache[key] = { + path: node_item + for path, node_item in path_to_item_map.items() + if node_item.last_used > cutoff_time + } + + parser_cache.setdefault(hashed_grammar, {})[path] = module_cache_item + + def save_module(hashed_grammar, file_io, module, lines, pickling=True, cache_path=None): path = file_io.path try: @@ -136,7 +169,7 @@ pickling = False item = _NodeCacheItem(module, lines, p_time) - parser_cache.setdefault(hashed_grammar, {})[path] = item + _set_cache_item(hashed_grammar, path, item) if pickling and path is not None: _save_to_file_system(hashed_grammar, path, item, cache_path=cache_path) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/grammar.py new/parso-0.6.1/parso/grammar.py --- old/parso-0.5.2/parso/grammar.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/grammar.py 2020-02-03 21:46:42.000000000 +0100 @@ -224,7 +224,7 @@ Loads a :py:class:`parso.Grammar`. The default version is the current Python version. - :param str version: A python version string, e.g. ``version='3.3'``. + :param str version: A python version string, e.g. ``version='3.8'``. :param str path: A path to a grammar file """ def load_grammar(language='python', version=None, path=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/normalizer.py new/parso-0.6.1/parso/normalizer.py --- old/parso-0.5.2/parso/normalizer.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/normalizer.py 2020-02-03 21:46:42.000000000 +0100 @@ -119,7 +119,6 @@ class Issue(object): def __init__(self, node, code, message): - self._node = node self.code = code """ An integer code that stands for the type of error. @@ -133,6 +132,7 @@ The start position position of the error as a tuple (line, column). As always in |parso| the first line is 1 and the first column 0. """ + self.end_pos = node.end_pos def __eq__(self, other): return self.start_pos == other.start_pos and self.code == other.code diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/python/errors.py new/parso-0.6.1/parso/python/errors.py --- old/parso-0.5.2/parso/python/errors.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/python/errors.py 2020-02-03 21:46:42.000000000 +0100 @@ -176,8 +176,7 @@ self._analyze_names(self._global_names, 'global') self._analyze_names(self._nonlocal_names, 'nonlocal') - # Python2.6 doesn't have dict comprehensions. - global_name_strs = dict((n.value, n) for n in self._global_names) + global_name_strs = {n.value: n for n in self._global_names} for nonlocal_name in self._nonlocal_names: try: global_name = global_name_strs[nonlocal_name.value] @@ -864,6 +863,7 @@ @ErrorFinder.register_rule(type='fstring') class _FStringRule(SyntaxRule): _fstring_grammar = None + message_expr = "f-string expression part cannot include a backslash" message_nested = "f-string: expressions nested too deeply" message_conversion = "f-string: invalid conversion character: expected 's', 'r', or 'a'" @@ -874,6 +874,10 @@ if depth >= 2: self.add_issue(fstring_expr, message=self.message_nested) + expr = fstring_expr.children[1] + if '\\' in expr.get_code(): + self.add_issue(expr, message=self.message_expr) + conversion = fstring_expr.children[2] if conversion.type == 'fstring_conversion': name = conversion.children[1] @@ -915,6 +919,14 @@ if second.type == 'yield_expr': error = 'yield expression' elif second.type == 'testlist_comp': + # ([a, b] := [1, 2]) + # ((a, b) := [1, 2]) + if is_namedexpr: + if first == '(': + error = 'tuple' + elif first == '[': + error = 'list' + # This is not a comprehension, they were handled # further above. for child in second.children[::2]: @@ -964,6 +976,8 @@ if error is not None: if is_namedexpr: + # c.f. CPython bpo-39176, should be changed in next release + # message = 'cannot use assignment expressions with %s' % error message = 'cannot use named assignment with %s' % error else: cannot = "can't" if self._normalizer.version < (3, 8) else "cannot" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/python/grammar26.txt new/parso-0.6.1/parso/python/grammar26.txt --- old/parso-0.5.2/parso/python/grammar26.txt 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/python/grammar26.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1,159 +0,0 @@ -# Grammar for Python - -# Note: Changing the grammar specified in this file will most likely -# require corresponding changes in the parser module -# (../Modules/parsermodule.c). If you can't make the changes to -# that module yourself, please co-ordinate the required changes -# with someone who can; ask around on python-dev for help. Fred -# Drake <[email protected]> will probably be listening there. - -# NOTE WELL: You should also follow all the steps listed in PEP 306, -# "How to Change Python's Grammar" - -# Commands for Kees Blom's railroad program -#diagram:token NAME -#diagram:token NUMBER -#diagram:token STRING -#diagram:token NEWLINE -#diagram:token ENDMARKER -#diagram:token INDENT -#diagram:output\input python.bla -#diagram:token DEDENT -#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm -#diagram:rules - -# Start symbols for the grammar: -# single_input is a single interactive statement; -# file_input is a module or sequence of commands read from an input file; -# eval_input is the input for the eval() and input() functions. -# NB: compound_stmt in single_input is followed by extra NEWLINE! -single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -file_input: (NEWLINE | stmt)* ENDMARKER -eval_input: testlist NEWLINE* ENDMARKER - -decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE -decorators: decorator+ -decorated: decorators (classdef | funcdef) -funcdef: 'def' NAME parameters ':' suite -parameters: '(' [varargslist] ')' -varargslist: ((fpdef ['=' test] ',')* - ('*' NAME [',' '**' NAME] | '**' NAME) | - fpdef ['=' test] (',' fpdef ['=' test])* [',']) -fpdef: NAME | '(' fplist ')' -fplist: fpdef (',' fpdef)* [','] - -stmt: simple_stmt | compound_stmt -simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE -small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | - import_stmt | global_stmt | exec_stmt | assert_stmt) -expr_stmt: testlist (augassign (yield_expr|testlist) | - ('=' (yield_expr|testlist))*) -augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | - '<<=' | '>>=' | '**=' | '//=') -# For normal assignments, additional restrictions enforced by the interpreter -print_stmt: 'print' ( [ test (',' test)* [','] ] | - '>>' test [ (',' test)+ [','] ] ) -del_stmt: 'del' exprlist -pass_stmt: 'pass' -flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt -break_stmt: 'break' -continue_stmt: 'continue' -return_stmt: 'return' [testlist] -yield_stmt: yield_expr -raise_stmt: 'raise' [test [',' test [',' test]]] -import_stmt: import_name | import_from -import_name: 'import' dotted_as_names -import_from: ('from' ('.'* dotted_name | '.'+) - 'import' ('*' | '(' import_as_names ')' | import_as_names)) -import_as_name: NAME ['as' NAME] -dotted_as_name: dotted_name ['as' NAME] -import_as_names: import_as_name (',' import_as_name)* [','] -dotted_as_names: dotted_as_name (',' dotted_as_name)* -dotted_name: NAME ('.' NAME)* -global_stmt: 'global' NAME (',' NAME)* -exec_stmt: 'exec' expr ['in' test [',' test]] -assert_stmt: 'assert' test [',' test] - -compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated -if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] -while_stmt: 'while' test ':' suite ['else' ':' suite] -for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] -try_stmt: ('try' ':' suite - ((except_clause ':' suite)+ - ['else' ':' suite] - ['finally' ':' suite] | - 'finally' ':' suite)) -with_stmt: 'with' with_item ':' suite -# Dave: Python2.6 actually defines a little bit of a different label called -# 'with_var'. However in 2.7+ this is the default. Apply it for -# consistency reasons. -with_item: test ['as' expr] -# NB compile.c makes sure that the default except clause is last -except_clause: 'except' [test [('as' | ',') test]] -suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT - -# Backward compatibility cruft to support: -# [ x for x in lambda: True, lambda: False if x() ] -# even while also allowing: -# lambda x: 5 if x else 2 -# (But not a mix of the two) -testlist_safe: old_test [(',' old_test)+ [',']] -old_test: or_test | old_lambdef -old_lambdef: 'lambda' [varargslist] ':' old_test - -test: or_test ['if' or_test 'else' test] | lambdef -or_test: and_test ('or' and_test)* -and_test: not_test ('and' not_test)* -not_test: 'not' not_test | comparison -comparison: expr (comp_op expr)* -comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' -expr: xor_expr ('|' xor_expr)* -xor_expr: and_expr ('^' and_expr)* -and_expr: shift_expr ('&' shift_expr)* -shift_expr: arith_expr (('<<'|'>>') arith_expr)* -arith_expr: term (('+'|'-') term)* -term: factor (('*'|'/'|'%'|'//') factor)* -factor: ('+'|'-'|'~') factor | power -power: atom trailer* ['**' factor] -atom: ('(' [yield_expr|testlist_comp] ')' | - '[' [listmaker] ']' | - '{' [dictorsetmaker] '}' | - '`' testlist1 '`' | - NAME | NUMBER | strings) -strings: STRING+ -listmaker: test ( list_for | (',' test)* [','] ) -# Dave: Renamed testlist_gexpr to testlist_comp, because in 2.7+ this is the -# default. It's more consistent like this. -testlist_comp: test ( gen_for | (',' test)* [','] ) -lambdef: 'lambda' [varargslist] ':' test -trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME -subscriptlist: subscript (',' subscript)* [','] -subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] -sliceop: ':' [test] -exprlist: expr (',' expr)* [','] -testlist: test (',' test)* [','] -# Dave: Rename from dictmaker to dictorsetmaker, because this is more -# consistent with the following grammars. -dictorsetmaker: test ':' test (',' test ':' test)* [','] - -classdef: 'class' NAME ['(' [testlist] ')'] ':' suite - -arglist: (argument ',')* (argument [','] - |'*' test (',' argument)* [',' '**' test] - |'**' test) -argument: test [gen_for] | test '=' test # Really [keyword '='] test - -list_iter: list_for | list_if -list_for: 'for' exprlist 'in' testlist_safe [list_iter] -list_if: 'if' old_test [list_iter] - -gen_iter: gen_for | gen_if -gen_for: 'for' exprlist 'in' or_test [gen_iter] -gen_if: 'if' old_test [gen_iter] - -testlist1: test (',' test)* - -# not used in grammar, but may appear in "node" passed from Parser to Compiler -encoding_decl: NAME - -yield_expr: 'yield' [testlist] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/python/parser.py new/parso-0.6.1/parso/python/parser.py --- old/parso-0.5.2/parso/python/parser.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/python/parser.py 2020-02-03 21:46:42.000000000 +0100 @@ -44,8 +44,6 @@ # avoid extreme amounts of work around the subtle difference of 2/3 # grammar in list comoprehensions. 'list_for': tree.SyncCompFor, - # Same here. This just exists in Python 2.6. - 'gen_for': tree.SyncCompFor, 'decorator': tree.Decorator, 'lambdef': tree.Lambda, 'old_lambdef': tree.Lambda, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/python/tokenize.py new/parso-0.6.1/parso/python/tokenize.py --- old/parso-0.5.2/parso/python/tokenize.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/python/tokenize.py 2020-02-03 21:46:42.000000000 +0100 @@ -19,7 +19,6 @@ from codecs import BOM_UTF8 from parso.python.token import PythonTokenTypes -from parso._compatibility import py_version from parso.utils import split_lines @@ -50,7 +49,7 @@ _token_collection_cache = {} -if py_version >= 30: +if sys.version_info.major >= 3: # Python 3 has str.isidentifier() to check if a char is a valid identifier is_identifier = str.isidentifier else: @@ -86,7 +85,7 @@ # and don't contain any permuations (include 'fr', but not # 'rf'). The various permutations will be generated. valid_string_prefixes = ['b', 'r', 'u'] - if version_info >= (3, 0): + if version_info.major >= 3: valid_string_prefixes.append('br') result = set(['']) @@ -106,7 +105,7 @@ # create a list with upper and lower versions of each # character result.update(different_case_versions(t)) - if version_info <= (2, 7): + if version_info.major == 2: # In Python 2 the order cannot just be random. result.update(different_case_versions('ur')) result.update(different_case_versions('br')) @@ -164,7 +163,7 @@ else: Hexnumber = r'0[xX][0-9a-fA-F]+' Binnumber = r'0[bB][01]+' - if version_info >= (3, 0): + if version_info.major >= 3: Octnumber = r'0[oO][0-7]+' else: Octnumber = '0[oO]?[0-7]+' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/python/tree.py new/parso-0.6.1/parso/python/tree.py --- old/parso-0.5.2/parso/python/tree.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/python/tree.py 2020-02-03 21:46:42.000000000 +0100 @@ -57,10 +57,14 @@ _FLOW_CONTAINERS = set(['if_stmt', 'while_stmt', 'for_stmt', 'try_stmt', 'with_stmt', 'async_stmt', 'suite']) _RETURN_STMT_CONTAINERS = set(['suite', 'simple_stmt']) | _FLOW_CONTAINERS -_FUNC_CONTAINERS = set(['suite', 'simple_stmt', 'decorated']) | _FLOW_CONTAINERS + +_FUNC_CONTAINERS = set( + ['suite', 'simple_stmt', 'decorated', 'async_funcdef'] +) | _FLOW_CONTAINERS + _GET_DEFINITION_TYPES = set([ 'expr_stmt', 'sync_comp_for', 'with_stmt', 'for_stmt', 'import_name', - 'import_from', 'param' + 'import_from', 'param', 'del_stmt', ]) _IMPORTS = set(['import_name', 'import_from']) @@ -95,7 +99,7 @@ class PythonMixin(object): """ - Some Python specific utitilies. + Some Python specific utilities. """ __slots__ = () @@ -233,6 +237,8 @@ while node is not None: if node.type == 'suite': return None + if node.type == 'namedexpr_test': + return node.children[0] if node.type in _GET_DEFINITION_TYPES: if self in node.get_defined_names(include_setitem): return node @@ -993,6 +999,14 @@ def keyword(self): return self.children[0].value + def get_defined_names(self, include_setitem=False): + keyword = self.keyword + if keyword == 'del': + return _defined_names(self.children[1], include_setitem) + if keyword in ('global', 'nonlocal'): + return self.children[1::2] + return [] + class AssertStmt(KeywordStatement): __slots__ = () diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/tree.py new/parso-0.6.1/parso/tree.py --- old/parso-0.5.2/parso/tree.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/tree.py 2020-02-03 21:46:42.000000000 +0100 @@ -1,6 +1,7 @@ +import sys from abc import abstractmethod, abstractproperty -from parso._compatibility import utf8_repr, encoding, py_version +from parso._compatibility import utf8_repr, encoding from parso.utils import split_lines @@ -321,7 +322,7 @@ @utf8_repr def __repr__(self): code = self.get_code().replace('\n', ' ').replace('\r', ' ').strip() - if not py_version >= 30: + if not sys.version_info.major >= 3: code = code.encode(encoding, 'replace') return "<%s: %s@%s,%s>" % \ (type(self).__name__, code, self.start_pos[0], self.start_pos[1]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso/utils.py new/parso-0.6.1/parso/utils.py --- old/parso-0.5.2/parso/utils.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/parso/utils.py 2020-02-03 21:46:42.000000000 +0100 @@ -2,8 +2,9 @@ import re import sys from ast import literal_eval +from functools import total_ordering -from parso._compatibility import unicode, total_ordering +from parso._compatibility import unicode # The following is a list in Python that are line breaks in str.splitlines, but # not in Python. In Python only \r (Carriage Return, 0xD) and \n (Line Feed, @@ -122,7 +123,7 @@ match = re.match(r'(\d+)(?:\.(\d)(?:\.\d+)?)?$', version) if match is None: raise ValueError('The given version is not in the right format. ' - 'Use something like "3.2" or "3".') + 'Use something like "3.8" or "3".') major = int(match.group(1)) minor = match.group(2) @@ -163,13 +164,13 @@ def parse_version_string(version=None): """ - Checks for a valid version number (e.g. `3.2` or `2.7.1` or `3`) and + Checks for a valid version number (e.g. `3.8` or `2.7.1` or `3`) and returns a corresponding version info that is always two characters long in decimal. """ if version is None: version = '%s.%s' % sys.version_info[:2] if not isinstance(version, (unicode, str)): - raise TypeError("version must be a string like 3.2.") + raise TypeError('version must be a string like "3.8"') return _parse_version(version) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso.egg-info/PKG-INFO new/parso-0.6.1/parso.egg-info/PKG-INFO --- old/parso-0.5.2/parso.egg-info/PKG-INFO 2019-12-15 01:01:27.000000000 +0100 +++ new/parso-0.6.1/parso.egg-info/PKG-INFO 2020-02-03 22:05:10.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: parso -Version: 0.5.2 +Version: 0.6.1 Summary: A Python Parser Home-page: https://github.com/davidhalter/parso Author: David Halter @@ -106,6 +106,20 @@ Changelog --------- + 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) ++++++++++++++++++ @@ -194,10 +208,8 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 @@ -205,4 +217,5 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Text Editors :: Integrated Development Environments (IDE) Classifier: Topic :: Utilities +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* Provides-Extra: testing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/parso.egg-info/SOURCES.txt new/parso-0.6.1/parso.egg-info/SOURCES.txt --- old/parso-0.5.2/parso.egg-info/SOURCES.txt 2019-12-15 01:01:27.000000000 +0100 +++ new/parso-0.6.1/parso.egg-info/SOURCES.txt 2020-02-03 22:05:10.000000000 +0100 @@ -49,7 +49,6 @@ parso/python/__init__.py parso/python/diff.py parso/python/errors.py -parso/python/grammar26.txt parso/python/grammar27.txt parso/python/grammar33.txt parso/python/grammar34.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/setup.py new/parso-0.6.1/setup.py --- old/parso-0.5.2/setup.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/setup.py 2020-02-03 21:46:42.000000000 +0100 @@ -27,6 +27,7 @@ packages=find_packages(exclude=['test']), package_data={'parso': ['python/grammar*.txt']}, platforms=['any'], + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Plugins', @@ -34,10 +35,8 @@ 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/failing_examples.py new/parso-0.6.1/test/failing_examples.py --- old/parso-0.5.2/test/failing_examples.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/failing_examples.py 2020-02-03 21:46:42.000000000 +0100 @@ -281,11 +281,11 @@ # Same as above, but for f-strings. 'f"s" b""', 'b"s" f""', + + # f-string expression part cannot include a backslash + r'''f"{'\n'}"''', ] -if sys.version_info >= (2, 7): - # This is something that raises a different error in 2.6 than in the other - # versions. Just skip it for 2.6. - FAILING_EXAMPLES.append('[a, 1] += 3') +FAILING_EXAMPLES.append('[a, 1] += 3') if sys.version_info[:2] == (3, 5): # yields are not allowed in 3.5 async functions. Therefore test them @@ -350,4 +350,14 @@ # Not in that issue '(await a := x)', '((await a) := x)', + # new discoveries + '((a, b) := (1, 2))', + '([a, b] := [1, 2])', + '({a, b} := {1, 2})', + '({a: b} := {1: 2})', + '(a + b := 1)', + '(True := 1)', + '(False := 1)', + '(None := 1)', + '(__debug__ := 1)', ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/test_cache.py new/parso-0.6.1/test/test_cache.py --- old/parso-0.5.2/test/test_cache.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/test_cache.py 2020-02-03 21:46:42.000000000 +0100 @@ -5,12 +5,14 @@ from os import unlink import pytest +import time from parso.cache import _NodeCacheItem, save_module, load_module, \ _get_hashed_path, parser_cache, _load_from_file_system, _save_to_file_system from parso import load_grammar from parso import cache from parso import file_io +from parso import parse @pytest.fixture() @@ -87,3 +89,53 @@ cached2 = load_module(grammar._hashed, io) assert cached2 is None + + +def test_cache_limit(): + def cache_size(): + return sum(len(v) for v in parser_cache.values()) + + try: + parser_cache.clear() + future_node_cache_item = _NodeCacheItem('bla', [], change_time=time.time() + 10e6) + old_node_cache_item = _NodeCacheItem('bla', [], change_time=time.time() - 10e4) + parser_cache['some_hash_old'] = { + '/path/%s' % i: old_node_cache_item for i in range(300) + } + parser_cache['some_hash_new'] = { + '/path/%s' % i: future_node_cache_item for i in range(300) + } + assert cache_size() == 600 + parse('somecode', cache=True, path='/path/somepath') + assert cache_size() == 301 + finally: + parser_cache.clear() + + +class _FixedTimeFileIO(file_io.KnownContentFileIO): + def __init__(self, path, content, last_modified): + super(_FixedTimeFileIO, self).__init__(path, content) + self._last_modified = last_modified + + def get_last_modified(self): + return self._last_modified + + [email protected]('diff_cache', [False, True]) [email protected]('use_file_io', [False, True]) +def test_cache_last_used_update(diff_cache, use_file_io): + p = '/path/last-used' + parser_cache.clear() # Clear, because then it's easier to find stuff. + parse('somecode', cache=True, path=p) + node_cache_item = next(iter(parser_cache.values()))[p] + now = time.time() + assert node_cache_item.last_used < now + + if use_file_io: + f = _FixedTimeFileIO(p, 'code', node_cache_item.last_used - 10) + parse(file_io=f, cache=True, diff_cache=diff_cache) + else: + parse('somecode2', cache=True, path=p, diff_cache=diff_cache) + + node_cache_item = next(iter(parser_cache.values()))[p] + assert now < node_cache_item.last_used < time.time() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/test_diff_parser.py new/parso-0.6.1/test/test_diff_parser.py --- old/parso-0.5.2/test/test_diff_parser.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/test_diff_parser.py 2020-02-03 21:46:42.000000000 +0100 @@ -989,7 +989,6 @@ differ.parse(' a( # xx\ndef', parsers=2, expect_error_leaves=True) [email protected](sys.version_info < (2, 7), reason="No set literals in Python 2.6") def test_dedent_end_positions(differ): code1 = dedent('''\ if 1: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/test_load_grammar.py new/parso-0.6.1/test/test_load_grammar.py --- old/parso-0.5.2/test/test_load_grammar.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/test_load_grammar.py 2020-02-03 21:46:42.000000000 +0100 @@ -28,4 +28,4 @@ def test_grammar_int_version(): with pytest.raises(TypeError): - load_grammar(version=3.2) + load_grammar(version=3.8) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/test_normalizer_issues_files.py new/parso-0.6.1/test/test_normalizer_issues_files.py --- old/parso-0.5.2/test/test_normalizer_issues_files.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/test_normalizer_issues_files.py 2020-02-03 21:46:42.000000000 +0100 @@ -5,9 +5,9 @@ import difflib import re +from functools import total_ordering import parso -from parso._compatibility import total_ordering from parso.utils import python_bytes_to_unicode diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/test_parser_tree.py new/parso-0.6.1/test/test_parser_tree.py --- old/parso-0.5.2/test/test_parser_tree.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/test_parser_tree.py 2020-02-03 21:46:42.000000000 +0100 @@ -142,7 +142,7 @@ def test_yield_from(): - y, = get_yield_exprs('def x(): (yield from 1)', '3.3') + y, = get_yield_exprs('def x(): (yield from 1)', '3.8') assert y.type == 'yield_expr' @@ -222,3 +222,19 @@ name = name.get_next_leaf() assert name.is_definition(include_setitem=include_setitem) == is_definition + + +def test_iter_funcdefs(): + code = dedent(''' + def normal(): ... + async def asyn(): ... + @dec + def dec_normal(): ... + @dec1 + @dec2 + async def dec_async(): ... + def broken + ''') + module = parse(code, version='3.8') + func_names = [f.name.value for f in module.iter_funcdefs()] + assert func_names == ['normal', 'asyn', 'dec_normal', 'dec_async'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/test_python_errors.py new/parso-0.6.1/test/test_python_errors.py --- old/parso-0.5.2/test/test_python_errors.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/test_python_errors.py 2020-02-03 21:46:42.000000000 +0100 @@ -37,7 +37,7 @@ error, = errors actual = error.message assert actual in wanted - # Somehow in Python3.3 the SyntaxError().lineno is sometimes None + # Somehow in Python2.7 the SyntaxError().lineno is sometimes None assert line_nr is None or line_nr == error.start_pos[0] @@ -118,22 +118,12 @@ assert False, "The piece of code should raise an exception." # SyntaxError - # Python 2.6 has a bit different error messages here, so skip it. - if sys.version_info[:2] == (2, 6) and wanted == 'SyntaxError: unexpected EOF while parsing': - wanted = 'SyntaxError: invalid syntax' - if wanted == 'SyntaxError: non-keyword arg after keyword arg': # The python 3.5+ way, a bit nicer. wanted = 'SyntaxError: positional argument follows keyword argument' elif wanted == 'SyntaxError: assignment to keyword': return [wanted, "SyntaxError: can't assign to keyword", 'SyntaxError: cannot assign to __debug__'], line_nr - elif wanted == 'SyntaxError: assignment to None': - # Python 2.6 does has a slightly different error. - wanted = 'SyntaxError: cannot assign to None' - elif wanted == 'SyntaxError: can not assign to __debug__': - # Python 2.6 does has a slightly different error. - wanted = 'SyntaxError: cannot assign to __debug__' elif wanted == 'SyntaxError: can use starred expression only as assignment target': # Python 3.4/3.4 have a bit of a different warning than 3.5/3.6 in # certain places. But in others this error makes sense. @@ -331,4 +321,3 @@ def test_trailing_comma(code): errors = _get_error_list(code) assert not errors - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/test/test_tokenize.py new/parso-0.6.1/test/test_tokenize.py --- old/parso-0.5.2/test/test_tokenize.py 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/test/test_tokenize.py 2020-02-03 21:46:42.000000000 +0100 @@ -4,8 +4,8 @@ from textwrap import dedent import pytest +import sys -from parso._compatibility import py_version from parso.utils import split_lines, parse_version_string from parso.python.token import PythonTokenTypes from parso.python import tokenize @@ -137,7 +137,7 @@ ''') token_list = _get_token_list(fundef) unicode_token = token_list[1] - if py_version >= 30: + if sys.version_info.major >= 3: assert unicode_token[0] == NAME else: # Unicode tokens in Python 2 seem to be identified as operators. @@ -185,19 +185,19 @@ assert typ == NAME check('u""') - check('ur""', is_literal=not py_version >= 30) - check('Ur""', is_literal=not py_version >= 30) - check('UR""', is_literal=not py_version >= 30) + check('ur""', is_literal=not sys.version_info.major >= 3) + check('Ur""', is_literal=not sys.version_info.major >= 3) + check('UR""', is_literal=not sys.version_info.major >= 3) check('bR""') # Starting with Python 3.3 this ordering is also possible. - if py_version >= 33: + if sys.version_info.major >= 3: check('Rb""') # Starting with Python 3.6 format strings where introduced. - check('fr""', is_literal=py_version >= 36) - check('rF""', is_literal=py_version >= 36) - check('f""', is_literal=py_version >= 36) - check('F""', is_literal=py_version >= 36) + check('fr""', is_literal=sys.version_info >= (3, 6)) + check('rF""', is_literal=sys.version_info >= (3, 6)) + check('f""', is_literal=sys.version_info >= (3, 6)) + check('F""', is_literal=sys.version_info >= (3, 6)) def test_error_literal(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parso-0.5.2/tox.ini new/parso-0.6.1/tox.ini --- old/parso-0.5.2/tox.ini 2019-12-15 01:01:11.000000000 +0100 +++ new/parso-0.6.1/tox.ini 2020-02-03 21:46:42.000000000 +0100 @@ -1,11 +1,9 @@ [tox] -envlist = {py26,py27,py33,py34,py35,py36,py37,py38} +envlist = {py27,py34,py35,py36,py37,py38} [testenv] extras = testing deps = - py26,py33: pytest>=3.0.7,<3.3 py27,py34: pytest<3.3 - py26,py33: setuptools<37 coverage: coverage setenv = # https://github.com/tomchristie/django-rest-framework/issues/1957
