Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-blue for openSUSE:Factory checked in at 2022-05-12 23:00:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-blue (Old) and /work/SRC/openSUSE:Factory/.python-blue.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-blue" Thu May 12 23:00:36 2022 rev:6 rq:976476 version:0.9.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-blue/python-blue.changes 2022-04-25 23:35:09.378385268 +0200 +++ /work/SRC/openSUSE:Factory/.python-blue.new.1538/python-blue.changes 2022-05-12 23:01:06.612857210 +0200 @@ -1,0 +2,8 @@ +Wed May 4 17:28:34 UTC 2022 - Matej Cepl <mc...@suse.com> + +- Upgrade to 0.9.0: + - Fix test suite failures due to a confluence of problems + - Upgrade dependency on Black to 22.1.0 to support Python 3.10 + - Add link to demo site at https://iblueit.dev + +------------------------------------------------------------------- Old: ---- blue-0.8.0.tar.gz New: ---- blue-0.9.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-blue.spec ++++++ --- /var/tmp/diff_new_pack.aNneGL/_old 2022-05-12 23:01:07.280858107 +0200 +++ /var/tmp/diff_new_pack.aNneGL/_new 2022-05-12 23:01:07.284858112 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 Name: python-blue -Version: 0.8.0 +Version: 0.9.0 Release: 0 Summary: A code formatter written in, and written for Python License: MIT @@ -67,6 +67,7 @@ %prep %autosetup -p1 -n blue-%{version} + # avoid pytest addopts for coverage checks sed -i '/--cov/d' tox.ini ++++++ blue-0.8.0.tar.gz -> blue-0.9.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/.gitignore new/blue-0.9.0/.gitignore --- old/blue-0.8.0/.gitignore 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/.gitignore 2022-05-02 22:25:15.000000000 +0200 @@ -19,3 +19,4 @@ # macOS metadata .DS_Store /blue/.mypy_cache/ +/.mypy_cache/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/README.rst new/blue-0.9.0/README.rst --- old/blue-0.8.0/README.rst 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/README.rst 2022-05-02 22:25:15.000000000 +0200 @@ -38,6 +38,7 @@ `black's <https://black.readthedocs.io/en/stable/>`_ documentation for anything not listed here. +Try it out now using `iblueit.dev <https://iblueit.dev/>`_. So what's different? ==================== @@ -118,3 +119,4 @@ * Report bugs and suggestions at: https://github.com/grantjenks/blue/issues * Code hosting: https://github.com/grantjenks/blue.git * Documentation: https://blue.readthedocs.io/en/latest +* Try it out: https://iblueit.dev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/blue/__init__.py new/blue-0.9.0/blue/__init__.py --- old/blue-0.8.0/blue/__init__.py 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/blue/__init__.py 2022-05-02 22:25:15.000000000 +0200 @@ -7,6 +7,61 @@ import re import sys +from importlib import machinery + +__version__ = '0.9.0' + + +# Black 1.0+ ships pre-compiled libraries with mypyc, which we can't +# monkeypatch like needed. In order to ensure that the original .py files get +# loaded instead, we create a custom FileFinder that excludes the +# ExtensionFileLoader, then use that as the file finder for Black's modules. +# However, we should perform this run time check to ensure we're not running +# in an environment we can't support. + +if 'black' in sys.modules and sys.modules['black'].__file__.endswith('.so'): + raise RuntimeError( + 'A mypyc-compiled version of black has already been imported. ' + 'This prevents blue from operating properly.' + ) + + +class NoMypycBlackFileFinder(machinery.FileFinder): + def __init__(self, path: str, *loader_details) -> None: + super().__init__(path, *loader_details) + + for hook in sys.path_hooks[1:]: + try: + self.original_finder = hook(path) + except ImportError: + continue + else: + break + else: + raise ImportError('Failed to find original import finder') + + def find_spec(self, fullname, *args, **kw): + if fullname == 'black' or fullname.startswith('black.'): + return super(NoMypycBlackFileFinder, self).find_spec( + fullname, *args, **kw + ) + else: + return self.original_finder.find_spec(fullname, *args, **kw) + + @classmethod + def path_hook(cls): + return super(NoMypycBlackFileFinder, cls).path_hook( + (machinery.SourceFileLoader, machinery.SOURCE_SUFFIXES), + (machinery.SourcelessFileLoader, machinery.BYTECODE_SUFFIXES), + ) + + +sys.path_hooks.insert(0, NoMypycBlackFileFinder.path_hook()) +sys.path_importer_cache.clear() + + +# These have to be imported after the import system hackery above, so we just +# ignore the E402 warning from flake8. import black import black.cache import black.comments @@ -36,13 +91,11 @@ from enum import Enum from functools import lru_cache -from typing import Any, Dict, Iterator, List, Optional +from typing import Any, Dict, Iterator, List, Optional, Pattern from click.decorators import version_option -__version__ = '0.8.0' - LOG = logging.getLogger(__name__) black_format_file_in_place = black.format_file_in_place @@ -126,6 +179,14 @@ return False +# Re(gex) does actually cache patterns internally but this still improves +# performance on a long list literal of strings by 5-9% since lru_cache's +# caching overhead is much lower. +@lru_cache(maxsize=64) +def _cached_compile(pattern: str) -> Pattern[str]: + return re.compile(pattern) + + def normalize_string_quotes(s: str) -> str: """Prefer *single* quotes but only if it doesn't cause more escaping. @@ -150,9 +211,9 @@ return s # There's an internal error prefix = s[:first_quote_pos] - unescaped_new_quote = re.compile(rf'(([^\\]|^)(\\\\)*){new_quote}') - escaped_new_quote = re.compile(rf'([^\\]|^)\\((?:\\\\)*){new_quote}') - escaped_orig_quote = re.compile(rf'([^\\]|^)\\((?:\\\\)*){orig_quote}') + unescaped_new_quote = _cached_compile(rf'(([^\\]|^)(\\\\)*){new_quote}') + escaped_new_quote = _cached_compile(rf'([^\\]|^)\\((?:\\\\)*){new_quote}') + escaped_orig_quote = _cached_compile(rf'([^\\]|^)\\((?:\\\\)*){orig_quote}') body = s[first_quote_pos + len(orig_quote) : -len(orig_quote)] if 'r' in prefix.casefold(): if unescaped_new_quote.search(body): @@ -174,9 +235,9 @@ if 'f' in prefix.casefold(): matches = re.findall( r""" - (?:[^{]|^)\{ # start of the string or a non-{ followed by a single { + (?:(?<!\{)|^)\{ # start of the string or a non-{ followed by a single { ([^{].*?) # contents of the brackets except if begins with {{ - \}(?:[^}]|$) # A } followed by end of the string or a non-} + \}(?:(?!\})|$) # A } followed by end of the string or a non-} """, new_body, re.VERBOSE, @@ -263,8 +324,8 @@ If parsing fails, will raise a tomli.TOMLDecodeError """ - with open(path_config, encoding="utf8") as f: - pyproject_toml = tomli.load(f) # type: ignore # due to deprecated API usage + with open(path_config, "rb") as f: + pyproject_toml = tomli.load(f) config = pyproject_toml.get("tool", {}).get("blue", {}) return {k.replace("--", "").replace("-", "_"): v for k, v in config.items()} @@ -283,7 +344,7 @@ if is_docstring(leaf) and "\\\n" not in leaf.value: # We're ignoring docstrings with backslash newline escapes because changing # indentation of those changes the AST representation of the code. - docstring = normalize_string_prefix(leaf.value, self.remove_u_prefix) + docstring = normalize_string_prefix(leaf.value) prefix = get_string_prefix(docstring) docstring = docstring[len(prefix) :] # Remove the prefix quote_char = docstring[0] @@ -333,9 +394,9 @@ try: - BaseConfigParser = flake8_config.ConfigParser # flake8 4 + BaseConfigParser = flake8_config.ConfigParser # flake8 v4 except AttributeError: - BaseConfigParser = flake8_config.MergedConfigParser # flake8 3 + BaseConfigParser = flake8_config.MergedConfigParser # flake8 v3 class MergedConfigParser(BaseConfigParser): @@ -387,7 +448,7 @@ 'Black', 'Blue' ) # Change the config param callback to support setup.cfg, tox.ini, etc. - config_param = black.main.params[21] + config_param = black.main.params[25] assert config_param.name == 'config' config_param.callback = read_configs # Change the version string by adding a redundant Click `version_option` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/docs/index.rst new/blue-0.9.0/docs/index.rst --- old/blue-0.8.0/docs/index.rst 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/docs/index.rst 2022-05-02 22:25:15.000000000 +0200 @@ -5,6 +5,13 @@ ======= +2022-05-02 (0.9.0) +------------------ +- Fix test suite failures due to a confluence of problems (GH#74) +- Upgrade dependency on Black to 22.1.0 to support Python 3.10 (GH#67) +- Add link to demo site at https://iblueit.dev (GH#69) + + 2022-02-22 (0.8.0) ------------------ - Fix compatibility with flake8 v4 (GH#58) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/setup.py new/blue-0.9.0/setup.py --- old/blue-0.8.0/setup.py 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/setup.py 2022-05-02 22:25:15.000000000 +0200 @@ -37,7 +37,7 @@ packages=['blue'], tests_require=['tox'], cmdclass={'test': Tox}, - install_requires=['black==21.7b0', 'flake8>=3.8'], + install_requires=['black==22.1.0', 'flake8>=3.8'], project_urls={ 'Documentation': 'https://blue.readthedocs.io/en/latest', 'Source': 'https://github.com/grantjenks/blue.git', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/tests/bad_cases/demo.py new/blue-0.9.0/tests/bad_cases/demo.py --- old/blue-0.8.0/tests/bad_cases/demo.py 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/tests/bad_cases/demo.py 2022-05-02 22:25:15.000000000 +0200 @@ -29,7 +29,7 @@ def f(a: List[int]): - return 37 - a[42 - u : y ** 3] + return 37 - a[42 - u : y**3] def very_important_function( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/tests/good_cases/demo.py new/blue-0.9.0/tests/good_cases/demo.py --- old/blue-0.8.0/tests/good_cases/demo.py 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/tests/good_cases/demo.py 2022-05-02 22:25:15.000000000 +0200 @@ -30,7 +30,7 @@ def f(a: List[int]): - return 37 - a[42 - u : y ** 3] + return 37 - a[42 - u : y**3] def very_important_function( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/tests/test_blue.py new/blue-0.9.0/tests/test_blue.py --- old/blue-0.8.0/tests/test_blue.py 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/tests/test_blue.py 2022-05-02 22:25:15.000000000 +0200 @@ -1,11 +1,16 @@ import asyncio import pathlib -import subprocess -import black +# blue must be imported before black. See GH#72. import blue +import black import pytest +from contextlib import ExitStack +from shutil import copy +from tempfile import TemporaryDirectory + + tests_dir = pathlib.Path(__file__).parent.absolute() @@ -20,16 +25,25 @@ ], ) def test_good_dirs(monkeypatch, test_dir): - test_dir = tests_dir / test_dir - monkeypatch.chdir(test_dir) - monkeypatch.setattr('sys.argv', ['blue', '--check', '.']) - for path in test_dir.rglob('*'): - path.touch() # Invalidate file caches in Blue. - black.find_project_root.cache_clear() - with pytest.raises(SystemExit) as exc_info: - asyncio.set_event_loop(asyncio.new_event_loop()) - blue.main() - assert exc_info.value.code == 0 + src_dir = tests_dir / test_dir + monkeypatch.setattr('sys.argv', ['blue', '--check', '--diff', '.']) + with TemporaryDirectory() as dst_dir: + # warsaw(2022-05-01): we can't use shutil.copytree() here until we + # drop Python 3.7 support because we need dirs_exist_ok and that was + # added in Python 3.8 + for path in src_dir.rglob('*'): + copy(src_dir / path, dst_dir) + monkeypatch.chdir(dst_dir) + black.find_project_root.cache_clear() + with pytest.raises(SystemExit) as exc_info: + asyncio.set_event_loop(asyncio.new_event_loop()) + blue.main() + # warsaw(2022-05-02): Change back to the srcdir now so that when the + # context manager exits, the dst_dir can be properly deleted. On + # Windows, that will fail if the process's cwd is still dst_dir. + # Python 3.11 has a contextlib.chdir() function we can use eventually. + monkeypatch.chdir(src_dir) + assert exc_info.value.code == 0 @pytest.mark.parametrize( @@ -37,19 +51,28 @@ ['bad_cases'], ) def test_bad_dirs(monkeypatch, test_dir): - test_dir = tests_dir / test_dir - monkeypatch.chdir(test_dir) - monkeypatch.setattr('sys.argv', ['blue', '--check', '.']) - for path in test_dir.rglob('*'): - path.touch() # Invalidate file caches in Blue. - black.find_project_root.cache_clear() - with pytest.raises(SystemExit) as exc_info: - asyncio.set_event_loop(asyncio.new_event_loop()) - blue.main() - assert exc_info.value.code == 1 + src_dir = tests_dir / test_dir + monkeypatch.setattr('sys.argv', ['blue', '--check', '--diff', '.']) + with TemporaryDirectory() as dst_dir: + # warsaw(2022-05-01): we can't use shutil.copytree() here until we + # drop Python 3.7 support because we need dirs_exist_ok and that was + # added in Python 3.8 + for path in src_dir.rglob('*'): + copy(src_dir / path, dst_dir) + monkeypatch.chdir(dst_dir) + black.find_project_root.cache_clear() + with pytest.raises(SystemExit) as exc_info: + asyncio.set_event_loop(asyncio.new_event_loop()) + blue.main() + # warsaw(2022-05-02): Change back to the srcdir now so that when the + # context manager exits, the dst_dir can be properly deleted. On + # Windows, that will fail if the process's cwd is still dst_dir. + # Python 3.11 has a contextlib.chdir() function we can use eventually. + monkeypatch.chdir(src_dir) + assert exc_info.value.code == 1 -def test_main(capsys, monkeypatch): +def test_main(monkeypatch): monkeypatch.setattr('sys.argv', ['blue', '--version']) with pytest.raises(SystemExit) as exc_info: import blue.__main__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blue-0.8.0/tox.ini new/blue-0.9.0/tox.ini --- old/blue-0.8.0/tox.ini 2022-02-22 18:57:49.000000000 +0100 +++ new/blue-0.9.0/tox.ini 2022-05-02 22:25:15.000000000 +0200 @@ -18,7 +18,7 @@ commands=blue blue docs setup.py tests/test_blue.py [testenv:bluecheck] -commands=blue --check blue docs setup.py tests/test_blue.py +commands=blue --check --diff blue docs setup.py tests/test_blue.py [testenv:docs] allowlist_externals=make @@ -56,5 +56,6 @@ E124 E203 E303 + E402 W503 max-line-length=88 ++++++ unpin-black.patch ++++++ --- /var/tmp/diff_new_pack.aNneGL/_old 2022-05-12 23:01:07.396858262 +0200 +++ /var/tmp/diff_new_pack.aNneGL/_new 2022-05-12 23:01:07.400858267 +0200 @@ -1,12 +1,15 @@ -Index: blue-0.8.0/blue/__init__.py -=================================================================== ---- blue-0.8.0.orig/blue/__init__.py -+++ blue-0.8.0/blue/__init__.py -@@ -387,8 +387,9 @@ def main(): +--- + blue/__init__.py | 5 +++-- + setup.py | 2 +- + 2 files changed, 4 insertions(+), 3 deletions(-) + +--- a/blue/__init__.py ++++ b/blue/__init__.py +@@ -448,8 +448,9 @@ def main(): 'Black', 'Blue' ) # Change the config param callback to support setup.cfg, tox.ini, etc. -- config_param = black.main.params[21] +- config_param = black.main.params[25] - assert config_param.name == 'config' + # the index changed somewhere between black 21.7b and 21.12b + cfgidx = {p.name: i for (i, p) in enumerate(black.main.params)}['config'] @@ -14,16 +17,14 @@ config_param.callback = read_configs # Change the version string by adding a redundant Click `version_option` # decorator on `black.main`. Fortunately the added `version_option` takes -Index: blue-0.8.0/setup.py -=================================================================== ---- blue-0.8.0.orig/setup.py -+++ blue-0.8.0/setup.py +--- a/setup.py ++++ b/setup.py @@ -37,7 +37,7 @@ setup( packages=['blue'], tests_require=['tox'], cmdclass={'test': Tox}, -- install_requires=['black==21.7b0', 'flake8>=3.8'], -+ install_requires=['black>=21.7b0', 'flake8>=3.8'], +- install_requires=['black==22.1.0', 'flake8>=3.8'], ++ install_requires=['black>=22.1.0', 'flake8>=3.8'], project_urls={ 'Documentation': 'https://blue.readthedocs.io/en/latest', 'Source': 'https://github.com/grantjenks/blue.git', ++++++ unpin-tomli.patch ++++++ --- /var/tmp/diff_new_pack.aNneGL/_old 2022-05-12 23:01:07.420858294 +0200 +++ /var/tmp/diff_new_pack.aNneGL/_new 2022-05-12 23:01:07.424858300 +0200 @@ -1,10 +1,10 @@ --- - blue/__init__.py | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) + blue/__init__.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) --- a/blue/__init__.py +++ b/blue/__init__.py -@@ -15,7 +15,10 @@ import black.strings +@@ -70,7 +70,10 @@ import black.strings from black import Leaf, Path, click, token from black.cache import user_cache_dir from black.comments import ProtoComment, make_comment @@ -16,15 +16,4 @@ from black.linegen import LineGenerator as BlackLineGenerator from black.lines import Line from black.nodes import ( -@@ -263,8 +266,8 @@ def parse_pyproject_toml(path_config: st - - If parsing fails, will raise a tomli.TOMLDecodeError - """ -- with open(path_config, encoding="utf8") as f: -- pyproject_toml = tomli.load(f) # type: ignore # due to deprecated API usage -+ with open(path_config, mode='rb') as f: -+ pyproject_toml = tomli.load(f) - config = pyproject_toml.get("tool", {}).get("blue", {}) - return {k.replace("--", "").replace("-", "_"): v for k, v in config.items()} -