Accepting request 956487 from home:dspinella:branches:home:mcepl:branches:devel:languages:python

ok

OBS-URL: https://build.opensuse.org/request/show/956487
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-libcst?expand=0&rev=16
This commit is contained in:
Matej Cepl 2022-02-21 13:47:06 +00:00 committed by Git OBS Bridge
parent 1409b90fdf
commit 3dc919d44d
9 changed files with 208 additions and 39 deletions

View File

@ -0,0 +1,40 @@
From d61f6cbd938c361fc746faff3d3d3ccfe273b9fc Mon Sep 17 00:00:00 2001
From: Stanislav Levin <slev@altlinux.org>
Date: Fri, 18 Feb 2022 13:18:04 +0300
Subject: [PATCH] tests: Fix assumption about sorting in test_ordering
The test wrongly assumed that `first_assignment.references`
is ordered collection, while actually it is `set`.
Fixes: https://github.com/Instagram/LibCST/issues/442
Signed-off-by: Stanislav Levin <slev@altlinux.org>
---
libcst/metadata/tests/test_scope_provider.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--- a/libcst/metadata/tests/test_scope_provider.py
+++ b/libcst/metadata/tests/test_scope_provider.py
@@ -1534,19 +1534,20 @@ class ScopeProviderTest(UnitTest):
first_assignment = list(global_scope.assignments)[0]
assert isinstance(first_assignment, cst.metadata.Assignment)
self.assertEqual(first_assignment.node, import_stmt)
- global_refs = list(first_assignment.references)
+ global_refs = first_assignment.references
self.assertEqual(len(global_refs), 2)
+ global_refs_nodes = {x.node for x in global_refs}
class_def = ensure_type(m.body[1], cst.ClassDef)
x = ensure_type(
ensure_type(class_def.body.body[0], cst.SimpleStatementLine).body[0],
cst.Assign,
)
- self.assertEqual(x.value, global_refs[0].node)
+ self.assertIn(x.value, global_refs_nodes)
class_b = ensure_type(
ensure_type(class_def.body.body[1], cst.SimpleStatementLine).body[0],
cst.Assign,
)
- self.assertEqual(class_b.value, global_refs[1].node)
+ self.assertIn(class_b.value, global_refs_nodes)
class_accesses = list(scopes[x].accesses)
self.assertEqual(len(class_accesses), 3)

3
LibCST-0.4.1.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d003592dd3133bed30bad2e4adc14d0e7a8e71ff6303345699164cdb7d0a1b9c
size 15812128

26
_service Normal file
View File

@ -0,0 +1,26 @@
<services>
<service mode="disabled" name="obs_scm">
<param name="url">https://github.com/Instagram/LibCST</param>
<param name="versionformat">@PARENT_TAG@</param>
<param name="scm">git</param>
<param name="revision">v0.4.1</param>
<param name="match-tag">*</param>
<param name="versionrewrite-pattern">v(\d+\.\d+\.\d+)</param>
<param name="versionrewrite-replacement">\1</param>
<param name="changesgenerate">disable</param>
</service>
<service mode="disabled" name="tar" />
<service mode="disabled" name="recompress">
<param name="file">*.tar</param>
<param name="compression">xz</param>
</service>
<service mode="disabled" name="set_version"/>
<service name="cargo_vendor" mode="disabled">
<param name="srcdir">LibCST/native</param>
<param name="compression">xz</param>
<param name="update">true</param>
</service>
<service name="cargo_audit" mode="disabled">
<param name="srcdir">LibCST/native</param>
</service>
</services>

10
cargo_config Normal file
View File

@ -0,0 +1,10 @@
[source.crates-io]
replace-with = "vendored-sources"
[source."https://github.com/kevinmehall/rust-peg"]
git = "https://github.com/kevinmehall/rust-peg"
rev = "4b146b4b78a80c07e43d7ace2d97f65bfde279a8"
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4876239db55164acaf034ee01f56a7db0a2f90cacea24b183d8aa69efc11b067
size 418419

View File

@ -1,3 +1,79 @@
-------------------------------------------------------------------
Fri Feb 18 21:32:48 UTC 2022 - Matej Cepl <mcepl@suse.com>
- Update to 0.4.1:
- Add docs about the native parts
- Specify minimum rust toolchain version
- build wheels on main branch for linux/arm64
- ApplyTypeAnnotationVisitor changes
- Add support for methods with func type comment excluding
self/cls
- Merge in TypeVars and Generic base classes in
ApplyTypeAnnotationVisitor
- Full handling for applying type comments to Assign
- Add support for For and With
- Support FunctionDef transformations
- change pyo3 as optional dependency in native Python Parser
- add slots to base classes, @add_slots takes bases into
account
- [native] Box most enums
- [native] Return tuples instead of lists in CST nodes
- Allow trailing whitespace without newline at EOF
- Handle ast.parse failures when converting function type
comments
- [native] Don't redundantly nest StarredElement inside another
Element
- [native] Allow unparenthesized tuples inside f-strings
- Don't require whitespace right after match
- Proxy both parentheses in some pattern matching nodes
- Update to 0.4.0 - 2022-01-12
This release contains a new parsing infrastructure that is
turned off by default. You can enable it by setting the
LIBCST_PARSER_TYPE environment variable to native before
parsing an input with the usual LibCST APIs. Parsing Python
3.10 documents is only supported in this new mode.
Note: the new parser is built as a native extension, so LibCST
will ship with binary wheels from now on.
- Implement a Python PEG parser in Rust
- implement PEP-654: except*
- Implement PEP-634 - Match statement
- Add instructions to codegen test failures
- Support Parenthesized With Statements
- Support relative imports in AddImportsVisitor
- Codemod for PEP 484 Assign w / type comments -> PEP 526
AnnAssign
- Update license headers
- Use precise signature matching when inserting function type
annotations
- Update to 0.3.23 - 2021-11-23
- Fix missing string annotation references
- Update to 0.3.22 - 2021-11-22
- Add --indent-string option to libcst.tool print
- Publish pre-release packages to test.pypi.org
- Add ImportAssignment class extending Assignment to record
assignments for import statements
- Do not add imports if we added no type info in
ApplyTypeAnnotationVisitor (commit)
- Support relative imports in ApplyTypeAnnotationVisitor
qualifier handling
- Don't gather metadata if the wrapper already contains it
- Swallow parsing errors in string annotations
- Stop parsing string annotations when no longer in a typing
call
- Move find_qualified_names_for in the Assignment class
- Update to 0.3.21 - 2021-09-21
- Fix pyre command for type inference provider
- Change codegen to treat typing.Union[Foo, NoneType] and
typing.Optional[Foo] as the same gh#Instagram/LibCST#508
- Rewrite the MatchIfTrue type to be generic on _MatchIfTrueT
- Update to 0.3.20 - 2021-08-09
- TypeAnnotationsVisitor: don't truncate function return type
-------------------------------------------------------------------
Wed May 19 15:49:13 UTC 2021 - Ben Greiner <code@bnavigator.de>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-libcst-test
# spec file
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -18,6 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
%define rustflags '-Clink-arg=-Wl,-z,relro,-z,now'
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
@ -27,25 +28,33 @@
%bcond_with test
%endif
Name: python-libcst%{psuffix}
Version: 0.3.19
Version: 0.4.1
Release: 0
Summary: Python 3.5+ concrete syntax tree with AST-like properties
License: MIT
URL: https://github.com/Instagram/LibCST
Source: https://files.pythonhosted.org/packages/source/l/libcst/libcst-%{version}.tar.gz
Source0: LibCST-%{version}.tar.xz
Source1: vendor.tar.xz
Source2: cargo_config
# PATCH-FIX-UPSTREAM skip_failing_test.patch gh#Instagram/LibCST#442 mcepl@suse.com
# test fails on i586 with Python 3.6
Patch0: skip_failing_test.patch
# PATCH-FIX-UPSTREAM 650-sorting-in-test_ordering.patch gh#Instagram/LibCST#650 mcepl@suse.com
# Fix assumption about sorting in test_ordering
Patch1: 650-sorting-in-test_ordering.patch
BuildRequires: %{python_module setuptools-rust}
BuildRequires: %{python_module setuptools_scm}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: cargo
BuildRequires: cargo-packaging
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: rust
Requires: python-PyYAML >= 5.2
Requires: python-typing-inspect >= 0.4.0
Requires: python-typing_extensions >= 3.7.4.2
BuildArch: noarch
%if %{python_version_nodots} < 37
Requires: python-dataclasses
%endif
Requires: (python-dataclasses if python-base < 3.7)
%if %{with test}
# black and isort needed for tests and the code regeneration
BuildRequires: %{python_module PyYAML >= 5.2}
@ -63,7 +72,9 @@ BuildRequires: %{python_module typing_extensions >= 3.7.4.2}
A concrete syntax tree with AST-like properties for Python 3.5+ programs.
%prep
%setup -q -n libcst-%{version}
%setup -q -n LibCST-%{version}
tar x -C native/ -f %{SOURCE1}
(cd native ; mkdir -p .cargo ; cat %{SOURCE2} >>.cargo/config.toml)
%autopatch -p1
# wrong executable call when outside of venv (gh#Instagram/LibCST#468)
@ -80,13 +91,23 @@ sed -i 's/import AbstractBaseMatcherNodeMeta/import Optional, AbstractBaseMatche
%if !%{with test}
%build
cd native
%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version}
%cargo_build
}
cd ..
%python_build
%endif
%install
%if !%{with test}
cd native
%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version}
%cargo_install
}
cd ..
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%endif
%if %{with test}
@ -103,8 +124,8 @@ $python -m unittest -v
%files %{python_files}
%doc README.rst
%license LICENSE
%{python_sitelib}/libcst
%{python_sitelib}/libcst-%{version}-py*.egg-info
%{python_sitearch}/libcst
%{python_sitearch}/libcst-%{version}-py*.egg-info
%endif
%changelog

View File

@ -1,27 +1,22 @@
Index: libcst-0.3.16/libcst/metadata/tests/test_scope_provider.py
===================================================================
--- libcst-0.3.16.orig/libcst/metadata/tests/test_scope_provider.py
+++ libcst-0.3.16/libcst/metadata/tests/test_scope_provider.py
@@ -5,6 +5,7 @@
import sys
+from sys import maxsize
from textwrap import dedent
from typing import Mapping, Tuple, cast
@@ -24,8 +25,9 @@ from libcst.metadata.scope_provider impo
---
libcst/metadata/tests/test_scope_provider.py | 5 ++++-
libcst/testing/utils.py | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
--- a/libcst/metadata/tests/test_scope_provider.py
+++ b/libcst/metadata/tests/test_scope_provider.py
@@ -28,7 +28,9 @@ from libcst.metadata.scope_provider impo
Scope,
ScopeProvider,
_gen_dotted_names,
)
-from libcst.testing.utils import UnitTest, data_provider
+from libcst.testing.utils import UnitTest, skipUnless, data_provider
-from libcst.testing.utils import data_provider, UnitTest
+from libcst.testing.utils import data_provider, skipUnless, UnitTest
+
+is_64bits = sys.maxsize > 2**32
+is_64bits = maxsize > 2**32
class DependentVisitor(cst.CSTVisitor):
METADATA_DEPENDENCIES = (ScopeProvider,)
@@ -1365,6 +1367,7 @@ class ScopeProviderTest(UnitTest):
@@ -1514,6 +1516,7 @@ class ScopeProviderTest(UnitTest):
}
self.assertEqual(names, {"a.b.c", "a.b", "a"})
@ -29,10 +24,8 @@ Index: libcst-0.3.16/libcst/metadata/tests/test_scope_provider.py
def test_ordering(self) -> None:
m, scopes = get_scope_metadata_provider(
"""
Index: libcst-0.3.16/libcst/testing/utils.py
===================================================================
--- libcst-0.3.16.orig/libcst/testing/utils.py
+++ libcst-0.3.16/libcst/testing/utils.py
--- a/libcst/testing/utils.py
+++ b/libcst/testing/utils.py
@@ -20,7 +20,7 @@ from typing import (
TypeVar,
Union,
@ -40,5 +33,5 @@ Index: libcst-0.3.16/libcst/testing/utils.py
-from unittest import TestCase
+from unittest import TestCase, skipUnless
DATA_PROVIDER_DATA_ATTR_NAME = "__data_provider_data"
DATA_PROVIDER_DESCRIPTION_PREFIX = "_data_provider_"

3
vendor.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9bb299695a933f47e65d2be722935f797b8664368fb86197dcf862429b23cbde
size 15092116