Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-libcst for openSUSE:Factory checked in at 2021-03-29 18:21:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-libcst (Old) and /work/SRC/openSUSE:Factory/.python-libcst.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-libcst" Mon Mar 29 18:21:06 2021 rev:5 rq:880613 version:0.3.17 Changes: -------- --- /work/SRC/openSUSE:Factory/python-libcst/python-libcst.changes 2021-01-08 17:32:01.429165586 +0100 +++ /work/SRC/openSUSE:Factory/.python-libcst.new.2401/python-libcst.changes 2021-03-29 18:21:09.686224397 +0200 @@ -1,0 +2,15 @@ +Sun Mar 21 15:05:59 UTC 2021 - Ben Greiner <c...@bnavigator.de> + +- Update ot 0.3.17 + Updated + * Optimization: reduce the number of unused parallel processes + #440 + Fixed + * Walrus operator's left hand side now has STORE expression + context #443 + * ApplyTypeAnnotationsVisitor applies parameter annotations even + if no return type is declared #445 + * Work around Windows problem by using dummy pool for jobs=1 #436 + * Remove extra unused imports added in other files #453 + +------------------------------------------------------------------- Old: ---- libcst-0.3.16.tar.gz New: ---- libcst-0.3.17.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-libcst.spec ++++++ --- /var/tmp/diff_new_pack.aBhD5r/_old 2021-03-29 18:21:10.190224913 +0200 +++ /var/tmp/diff_new_pack.aBhD5r/_new 2021-03-29 18:21:10.194224917 +0200 @@ -1,5 +1,5 @@ # -# spec file for package python-libcst +# spec file for package python-libcst-test # # Copyright (c) 2021 SUSE LLC # @@ -27,7 +27,7 @@ %bcond_with test %endif Name: python-libcst%{psuffix} -Version: 0.3.16 +Version: 0.3.17 Release: 0 Summary: Python 3.5+ concrete syntax tree with AST-like properties License: MIT @@ -36,8 +36,6 @@ # PATCH-FIX-UPSTREAM skip_failing_test.patch gh#Instagram/LibCST#442 mc...@suse.com # test fails on i586 with Python 3.6 Patch0: skip_failing_test.patch -# isort needed for the code regeneration, code mod also on non test flavor -BuildRequires: %{python_module isort >= 5.5.3} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros @@ -49,15 +47,15 @@ Requires: python-dataclasses %endif %if %{with test} +# black and isort needed for tests and the code regeneration BuildRequires: %{python_module PyYAML >= 5.2} -# black needed for tests and the code regeneration BuildRequires: %{python_module black} +BuildRequires: %{python_module dataclasses if %python-base < 3.7} BuildRequires: %{python_module hypothesis >= 4.36.0} BuildRequires: %{python_module hypothesmith >= 0.0.4} +BuildRequires: %{python_module isort >= 5.5.3} BuildRequires: %{python_module typing-inspect >= 0.4.0} BuildRequires: %{python_module typing_extensions >= 3.7.4.2} -BuildRequires: (python3-dataclasses if python3-base < 3.7) -BuildRequires: (python36-dataclasses if python36-base) %endif %python_subpackages @@ -68,8 +66,8 @@ %setup -q -n libcst-%{version} %autopatch -p1 -# fix executable -sed -i 's/"python"/sys.executable/' libcst/codemod/tests/test_codemod_cli.py +# wrong executable call, when fixed, fails to detect syntax error gh#Instagram/LibCST#468 +rm libcst/codemod/tests/test_codemod_cli.py # Depends on optional pyre rm \ @@ -77,6 +75,9 @@ libcst/metadata/tests/test_full_repo_manager.py \ libcst/tests/test_pyre_integration.py +# gh#Instagram/LibCST#467 +sed -i 's/import AbstractBaseMatcherNodeMeta/import Optional, AbstractBaseMatcherNodeMeta/' libcst/codegen/gen_matcher_classes.py + %if !%{with test} %build %python_build @@ -86,11 +87,20 @@ %if !%{with test} %python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} +# fix mtimes +%{python_compileall} +# need a double treatment here +%python_expand %fdupes %{buildroot}%{$python_sitelib} %endif %if %{with test} %check -%pyunittest -v +%{python_exec # https://github.com/Instagram/LibCST/issues/331 + 467 +$python -m libcst.codegen.generate matchers +$python -m libcst.codegen.generate return_types +$python -m libcst.codegen.generate visitors +$python -m unittest -v +} %endif %if !%{with test} ++++++ libcst-0.3.16.tar.gz -> libcst-0.3.17.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/PKG-INFO new/libcst-0.3.17/PKG-INFO --- old/libcst-0.3.16/PKG-INFO 2020-12-16 21:09:29.178212600 +0100 +++ new/libcst-0.3.17/PKG-INFO 2021-02-09 05:01:16.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: libcst -Version: 0.3.16 +Version: 0.3.17 Summary: A concrete syntax tree with AST-like properties for Python 3.5, 3.6, 3.7 and 3.8 programs. Home-page: https://github.com/Instagram/LibCST License: MIT @@ -186,6 +186,7 @@ 1. Copy the example Pyre config: ``cp .pyre_configuration.example .pyre_configuration``. 2. In the config file, add your venv site-packages dir to "search_path". (e.g. add "/workspace/libcst-env/lib/python3.7/site-packages") + Note: venv dir must **not** be inside the libcst dir 3. Remove installed LibCST and install from the source code: .. code-block:: shell diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/README.rst new/libcst-0.3.17/README.rst --- old/libcst-0.3.16/README.rst 2020-09-23 15:57:11.000000000 +0200 +++ new/libcst-0.3.17/README.rst 2021-02-08 22:02:49.000000000 +0100 @@ -180,6 +180,7 @@ 1. Copy the example Pyre config: ``cp .pyre_configuration.example .pyre_configuration``. 2. In the config file, add your venv site-packages dir to "search_path". (e.g. add "/workspace/libcst-env/lib/python3.7/site-packages") + Note: venv dir must **not** be inside the libcst dir 3. Remove installed LibCST and install from the source code: .. code-block:: shell diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst/_version.py new/libcst-0.3.17/libcst/_version.py --- old/libcst-0.3.16/libcst/_version.py 2020-12-16 21:08:40.000000000 +0100 +++ new/libcst-0.3.17/libcst/_version.py 2021-02-08 22:04:52.000000000 +0100 @@ -4,4 +4,4 @@ # LICENSE file in the root directory of this source tree. -LIBCST_VERSION: str = "0.3.16" +LIBCST_VERSION: str = "0.3.17" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst/codemod/_cli.py new/libcst-0.3.17/libcst/codemod/_cli.py --- old/libcst-0.3.16/libcst/codemod/_cli.py 2020-11-17 18:42:20.000000000 +0100 +++ new/libcst-0.3.17/libcst/codemod/_cli.py 2021-02-08 22:02:49.000000000 +0100 @@ -279,6 +279,7 @@ transformer.context, filename=filename, full_module_name=_calculate_module(config.repo_root, filename), + scratch={}, ) # Run the transform, bail if we failed or if we aren't formatting code @@ -576,8 +577,12 @@ total = len(files) progress = Progress(enabled=not hide_progress, total=total) + chunksize = 4 # Grab number of cores if we need to - jobs: int = jobs if jobs is not None else cpu_count() + jobs: int = min( + jobs if jobs is not None else cpu_count(), + (len(files) + chunksize - 1) // chunksize, + ) if jobs < 1: raise Exception("Must have at least one job to process!") @@ -614,7 +619,7 @@ python_version=python_version, ) - if total == 1: + if total == 1 or jobs == 1: # Simple case, we should not pay for process overhead. # Let's just use a dummy synchronous pool. jobs = 1 @@ -646,7 +651,9 @@ for filename in files ] try: - for result in p.imap_unordered(_execute_transform_wrap, args, chunksize=4): + for result in p.imap_unordered( + _execute_transform_wrap, args, chunksize=chunksize + ): # Print an execution result, keep track of failures _print_parallel_result( result, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst/codemod/visitors/_apply_type_annotations.py new/libcst-0.3.17/libcst/codemod/visitors/_apply_type_annotations.py --- old/libcst-0.3.16/libcst/codemod/visitors/_apply_type_annotations.py 2020-11-18 18:41:39.000000000 +0100 +++ new/libcst-0.3.17/libcst/codemod/visitors/_apply_type_annotations.py 2021-02-08 22:02:49.000000000 +0100 @@ -70,12 +70,16 @@ def visit_FunctionDef(self, node: cst.FunctionDef) -> bool: self.qualifier.append(node.name.value) returns = node.returns - if returns is not None: - return_annotation = self._create_import_from_annotation(returns) - parameter_annotations = self._import_parameter_annotations(node.params) - self.function_annotations[".".join(self.qualifier)] = FunctionAnnotation( - parameters=parameter_annotations, returns=return_annotation - ) + return_annotation = ( + self._create_import_from_annotation(returns) + if returns is not None + else None + ) + parameter_annotations = self._import_parameter_annotations(node.params) + self.function_annotations[".".join(self.qualifier)] = FunctionAnnotation( + parameters=parameter_annotations, returns=return_annotation + ) + # pyi files don't support inner functions, return False to stop the traversal. return False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst/codemod/visitors/tests/test_apply_type_annotations.py new/libcst-0.3.17/libcst/codemod/visitors/tests/test_apply_type_annotations.py --- old/libcst-0.3.16/libcst/codemod/visitors/tests/test_apply_type_annotations.py 2020-11-18 18:41:39.000000000 +0100 +++ new/libcst-0.3.17/libcst/codemod/visitors/tests/test_apply_type_annotations.py 2021-02-08 22:02:49.000000000 +0100 @@ -651,6 +651,24 @@ example: Dict[str, Type[foo.Example]] = { "test": foo() } """, ), + ( + """ + from typing import Optional + + class A: + def foo(self, atticus, b: Optional[int] = None, c: bool = False): ... + """, + """ + class A: + def foo(self, atticus, b = None, c = False): ... + """, + """ + from typing import Optional + + class A: + def foo(self, atticus, b: Optional[int] = None, c: bool = False): ... + """, + ), ) ) def test_annotate_functions(self, stub: str, before: str, after: str) -> None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst/test_docstring.py new/libcst-0.3.17/libcst/test_docstring.py --- old/libcst-0.3.16/libcst/test_docstring.py 1970-01-01 01:00:00.000000000 +0100 +++ new/libcst-0.3.17/libcst/test_docstring.py 2020-07-14 02:11:35.000000000 +0200 @@ -0,0 +1,7 @@ +# @oncall + +"""This is a module.""" + + +def f(): + pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst/tests/test_e2e.py new/libcst-0.3.17/libcst/tests/test_e2e.py --- old/libcst-0.3.16/libcst/tests/test_e2e.py 1970-01-01 01:00:00.000000000 +0100 +++ new/libcst-0.3.17/libcst/tests/test_e2e.py 2021-02-08 22:02:49.000000000 +0100 @@ -0,0 +1,77 @@ +import contextlib +import os +from pathlib import Path +from tempfile import TemporaryDirectory +from typing import Generator +from unittest import TestCase + +from libcst import BaseExpression, Call, Name, matchers as m +from libcst.codemod import ( + CodemodContext, + VisitorBasedCodemodCommand, + gather_files, + parallel_exec_transform_with_prettyprint, +) +from libcst.codemod.visitors import AddImportsVisitor + + +class PrintToPPrintCommand(VisitorBasedCodemodCommand): + def leave_Call(self, original_node: Call, updated_node: Call) -> BaseExpression: + if m.matches(updated_node, m.Call(func=m.Name("print"))): + AddImportsVisitor.add_needed_import( + self.context, + "pprint", + "pprint", + ) + return updated_node.with_changes(func=Name("pprint")) + return super().leave_Call(original_node, updated_node) + + +@contextlib.contextmanager +def temp_workspace() -> Generator[Path, None, None]: + cwd = os.getcwd() + with TemporaryDirectory() as temp_dir: + try: + ws = Path(temp_dir).resolve() + os.chdir(ws) + yield ws + finally: + os.chdir(cwd) + + +class ToolE2ETest(TestCase): + def test_leaky_codemod(self) -> None: + with temp_workspace() as tmp: + # File to trigger codemod + example: Path = tmp / "example.py" + example.write_text("""print("Hello")""") + # File that should not be modified + other = tmp / "other.py" + other.touch() + + # Run command + command_instance = PrintToPPrintCommand(CodemodContext()) + files = gather_files(".") + result = parallel_exec_transform_with_prettyprint( + command_instance, + files, + format_code=False, + hide_progress=True, + ) + + # Check results + self.assertEqual(2, result.successes) + self.assertEqual(0, result.skips) + self.assertEqual(0, result.failures) + # Expect example.py to be modified + self.assertIn( + "from pprint import pprint", + example.read_text(), + "import missing in example.py", + ) + # Expect other.py to NOT be modified + self.assertNotIn( + "from pprint import pprint", + other.read_text(), + "import found in other.py", + ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst.egg-info/PKG-INFO new/libcst-0.3.17/libcst.egg-info/PKG-INFO --- old/libcst-0.3.16/libcst.egg-info/PKG-INFO 2020-12-16 21:09:28.000000000 +0100 +++ new/libcst-0.3.17/libcst.egg-info/PKG-INFO 2021-02-09 05:01:15.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: libcst -Version: 0.3.16 +Version: 0.3.17 Summary: A concrete syntax tree with AST-like properties for Python 3.5, 3.6, 3.7 and 3.8 programs. Home-page: https://github.com/Instagram/LibCST License: MIT @@ -186,6 +186,7 @@ 1. Copy the example Pyre config: ``cp .pyre_configuration.example .pyre_configuration``. 2. In the config file, add your venv site-packages dir to "search_path". (e.g. add "/workspace/libcst-env/lib/python3.7/site-packages") + Note: venv dir must **not** be inside the libcst dir 3. Remove installed LibCST and install from the source code: .. code-block:: shell diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/libcst.egg-info/SOURCES.txt new/libcst-0.3.17/libcst.egg-info/SOURCES.txt --- old/libcst-0.3.16/libcst.egg-info/SOURCES.txt 2020-12-16 21:09:29.000000000 +0100 +++ new/libcst-0.3.17/libcst.egg-info/SOURCES.txt 2021-02-09 05:01:15.000000000 +0100 @@ -3,7 +3,6 @@ LICENSE MANIFEST.in README.rst -pyproject.toml requirements-dev.txt requirements.txt setup.py @@ -36,6 +35,7 @@ libcst/_version.py libcst/_visitors.py libcst/py.typed +libcst/test_docstring.py libcst/tool.py libcst.egg-info/PKG-INFO libcst.egg-info/SOURCES.txt @@ -273,6 +273,7 @@ libcst/tests/test_batched_visitor.py libcst/tests/test_deep_clone.py libcst/tests/test_deep_replace.py +libcst/tests/test_e2e.py libcst/tests/test_exceptions.py libcst/tests/test_fuzz.py libcst/tests/test_pyre_integration.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcst-0.3.16/pyproject.toml new/libcst-0.3.17/pyproject.toml --- old/libcst-0.3.16/pyproject.toml 2020-09-23 15:57:11.000000000 +0200 +++ new/libcst-0.3.17/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ -[tool.black] -target-version = ["py36"] - -[tool.isort] -line_length = 88 -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -lines_after_imports = 2 -combine_as_imports = true