Commit 78e7c232 authored by Justin Berthault's avatar Justin Berthault Committed by Leo
Browse files

community/py3-asttokens: upgrade to 2.0.5

parent 1d82e56a
# Contributor: Justin Berthault <justin.berthault@zaclys.net>
# Maintainer: Justin Berthault <justin.berthault@zaclys.net>
pkgname=py3-asttokens
pkgver=2.0.4
pkgrel=1
pkgver=2.0.5
pkgrel=0
pkgdesc="Annotate AST trees with source code positions"
url="https://github.com/gristlabs/asttokens"
arch="noarch"
......@@ -11,7 +11,6 @@ depends="python3 py3-six"
makedepends="py3-setuptools py3-setuptools_scm py3-wheel"
checkdepends="py3-astroid py3-pytest"
source="https://files.pythonhosted.org/packages/source/a/asttokens/asttokens-$pkgver.tar.gz
python-3.9.patch
"
builddir="$srcdir/"asttokens-$pkgver
......@@ -27,5 +26,4 @@ package() {
python3 setup.py install --prefix=/usr --root="$pkgdir"
}
sha512sums="2be6a2ddef35c45ed8b6576a35618b6bc1a4d8c50ab7ac2970d549e7310d46fc8a29fff514d58d6e01c984e04389ca8aee6efed510f349013ab8e2c867c98669 asttokens-2.0.4.tar.gz
044002bd96c2f738bb46222fa896c9f36ebde465a18ea30f6e1a9db25462719e852a479ee98ec4add219056f16e5aea2499ba2ecf8c70bacedefb3a7c0dcfd77 python-3.9.patch"
sha512sums="60b323be72de75b2d612e7d602a202fae46559f0842624d38ff0a22376573c3e4885ad2cece04314ef7f230f8e47ae6fc8d9f39a6bdacc1c74961a5158abd463 asttokens-2.0.5.tar.gz"
From d8ff80ee7d2e64c5e1daf50cc38eb99663f1b1ac Mon Sep 17 00:00:00 2001
From: Alex Hall <alex.mojaki@gmail.com>
Date: Fri, 26 Feb 2021 15:49:29 +0200
Subject: [PATCH] Make 3.9 support official, fix tests fo 3.9 involving starred
expressions (#66)
* Handle starred expressions in tests
* Make 3.9 support official
* pypy2 instead of pypy2.7
* pypy3 instead of pypy3.5
---
.travis.yml | 6 +++---
asttokens/util.py | 5 +++++
setup.cfg | 1 +
tests/test_mark_tokens.py | 3 +++
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index d86cffc..4276339 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,4 @@
-dist: xenial
+dist: bionic
language: python
sudo: false
@@ -9,8 +9,8 @@ python:
- 3.7
- 3.8-dev
- 3.9-dev
- - pypy2.7-6.0
- - pypy3.5
+ - pypy2
+ - pypy3
env:
global:
diff --git a/asttokens/util.py b/asttokens/util.py
index c29dd07..79ac430 100644
--- a/asttokens/util.py
+++ b/asttokens/util.py
@@ -142,6 +142,11 @@ def is_joined_str(node):
return node.__class__.__name__ == 'JoinedStr'
+def is_starred(node):
+ """Returns whether node is a starred expression node."""
+ return node.__class__.__name__ == 'Starred'
+
+
def is_slice(node):
"""Returns whether node represents a slice, e.g. `1:2` in `x[1:2]`"""
# Before 3.9, a tuple containing a slice is an ExtSlice,
diff --git a/tests/test_mark_tokens.py b/tests/test_mark_tokens.py
index a0f68b2..90cff20 100644
--- a/tests/test_mark_tokens.py
+++ b/tests/test_mark_tokens.py
@@ -728,9 +728,12 @@ def parse_snippet(self, text, node):
# For expressions and statements, we add a dummy statement '_' before it because if it's just a
# string contained in an astroid.Const or astroid.Expr it will end up in the doc attribute and be
# a pain to extract for comparison
+ # For starred expressions, e.g. `*args`, we wrap it in a function call to make it parsable.
indented = re.match(r'^[ \t]+\S', text)
if indented:
return self.module.parse('def dummy():\n' + text).body[0].body[0]
+ if util.is_starred(node):
+ return self.module.parse('f(' + text + ')').body[0].value.args[0]
if util.is_expr(node):
return self.module.parse('_\n(' + text + ')').body[1].value
if util.is_module(node):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment