Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-python-lsp-black for openSUSE:Factory checked in at 2024-01-06 18:09:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-python-lsp-black (Old) and /work/SRC/openSUSE:Factory/.python-python-lsp-black.new.28375 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-lsp-black" Sat Jan 6 18:09:19 2024 rev:8 rq:1137135 version:2.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-python-lsp-black/python-python-lsp-black.changes 2023-11-01 22:11:01.950005719 +0100 +++ /work/SRC/openSUSE:Factory/.python-python-lsp-black.new.28375/python-python-lsp-black.changes 2024-01-06 18:09:20.187674605 +0100 @@ -1,0 +2,11 @@ +Fri Jan 5 18:15:23 UTC 2024 - Dirk Müller <dmuel...@suse.com> + +- update to 2.0.0: + * Add support to format indented selections of code. This + requires Black 23.11.0+ + * Change entrypoint name to be `black`. This changes the + options namespace for this plugin from `pylsp.pylsp_black` + to `pylsp.black`. + * Drop support for Python 3.7. + +------------------------------------------------------------------- Old: ---- python-lsp-black-1.3.0-gh.tar.gz New: ---- python-lsp-black-2.0.0-gh.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-python-lsp-black.spec ++++++ --- /var/tmp/diff_new_pack.v3iUN0/_old 2024-01-06 18:09:21.015704864 +0100 +++ /var/tmp/diff_new_pack.v3iUN0/_new 2024-01-06 18:09:21.015704864 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-python-lsp-black # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,26 +16,27 @@ # +%{?sle15_python_module_pythons} Name: python-python-lsp-black -Version: 1.3.0 +Version: 2.0.0 Release: 0 Summary: Black plugin for the Python LSP Server License: MIT URL: https://github.com/python-lsp/python-lsp-black Source: https://github.com/python-lsp/python-lsp-black/archive/refs/tags/v%{version}.tar.gz#/python-lsp-black-%{version}-gh.tar.gz -BuildRequires: %{python_module base >= 3.7} +BuildRequires: %{python_module base >= 3.8} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wheel} BuildRequires: python-rpm-macros # SECTION test requirements -BuildRequires: %{python_module black >= 22.3.0} +BuildRequires: %{python_module black >= 23.11.0} BuildRequires: %{python_module pytest} BuildRequires: %{python_module python-lsp-server >= 1.4.0} BuildRequires: %{python_module tomli if %python-base < 3.11} # /SECTION BuildRequires: fdupes -Requires: python-black >= 22.3.0 +Requires: python-black >= 23.11.0 Requires: python-python-lsp-server >= 1.4 %if 0%{?python_version_nodots} < 311 Requires: python-tomli ++++++ python-lsp-black-1.3.0-gh.tar.gz -> python-lsp-black-2.0.0-gh.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/.github/workflows/python.yml new/python-lsp-black-2.0.0/.github/workflows/python.yml --- old/python-lsp-black-1.3.0/.github/workflows/python.yml 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/.github/workflows/python.yml 2023-12-19 02:48:52.000000000 +0100 @@ -11,7 +11,7 @@ runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/CHANGELOG.md new/python-lsp-black-2.0.0/CHANGELOG.md --- old/python-lsp-black-1.3.0/CHANGELOG.md 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/CHANGELOG.md 2023-12-19 02:48:52.000000000 +0100 @@ -1,3 +1,30 @@ +# History of changes + +## Version 2.0.0 (2023-12-19) + +### New features + +* Add support to format indented selections of code. This requires Black 23.11.0+ +* Change entrypoint name to be `black`. This changes the options namespace for + this plugin from `pylsp.pylsp_black` to `pylsp.black`. +* Drop support for Python 3.7. + +### Issues Closed + +* [Issue 42](https://github.com/python-lsp/python-lsp-black/issues/42) - Ineffective range formatting ([PR 52](https://github.com/python-lsp/python-lsp-black/pull/52) by [@remisalmon](https://github.com/remisalmon)) +* [Issue 41](https://github.com/python-lsp/python-lsp-black/issues/41) - Configuration key and plugin name mismatch ([PR 39](https://github.com/python-lsp/python-lsp-black/pull/39) by [@chantera](https://github.com/chantera)) + +In this release 2 issues were closed. + +### Pull Requests Merged + +* [PR 53](https://github.com/python-lsp/python-lsp-black/pull/53) - Drop support for Python 3.7, by [@ccordoba12](https://github.com/ccordoba12) +* [PR 52](https://github.com/python-lsp/python-lsp-black/pull/52) - Use new `lines` option in Black 23.11 to format range, by [@remisalmon](https://github.com/remisalmon) ([42](https://github.com/python-lsp/python-lsp-black/issues/42)) +* [PR 49](https://github.com/python-lsp/python-lsp-black/pull/49) - Read skip options from plugin settings, by [@seruman](https://github.com/seruman) +* [PR 39](https://github.com/python-lsp/python-lsp-black/pull/39) - Change entrypoint name to simply be `black`, by [@chantera](https://github.com/chantera) ([41](https://github.com/python-lsp/python-lsp-black/issues/41)) + +In this release 4 pull requests were closed. + ## Version 1.3.0 (2023/05/19) ### Issues Closed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/README.md new/python-lsp-black-2.0.0/README.md --- old/python-lsp-black-1.3.0/README.md 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/README.md 2023-12-19 02:48:52.000000000 +0100 @@ -45,7 +45,9 @@ setting. Defaults to 88 (same as black's default). This can also be set through black's configuration files, which should be preferred for multi-user projects. - `pylsp.plugins.black.preview`: a boolean to enable or disable [black's `--preview` - setting](https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#preview-style). + setting](https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#preview-style). `false` by default. +- `pylsp.plugins.black.skip_string_normalization`: a boolean to enable or disable black's `--skip-string-normalization` setting. `false` by default. +- `pylsp.plugins.black.skip_magic_trailing_comma`: a boolean to enable or disable black's `skip-magic-trailing-comma` setting. `false` by default. # Development diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/pylsp_black/plugin.py new/python-lsp-black-2.0.0/pylsp_black/plugin.py --- old/python-lsp-black-1.3.0/pylsp_black/plugin.py 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/pylsp_black/plugin.py 2023-12-19 02:48:52.000000000 +0100 @@ -64,29 +64,34 @@ def format_document(client_config, document, range=None): + text = document.source + config = load_config(document.path, client_config) + # Black lines indices are "1-based and inclusive on both ends" + lines = [(range["start"]["line"] + 1, range["end"]["line"])] if range else () + + try: + formatted_text = format_text(text=text, config=config, lines=lines) + except black.NothingChanged: + # raised when the file is already formatted correctly + return [] + if range: + formatted_lines = formatted_text.splitlines(True) + start = range["start"]["line"] - end = range["end"]["line"] - text = "".join(document.lines[start:end]) + end = range["end"]["line"] + (len(formatted_lines) - len(document.lines)) + + formatted_text = "".join(formatted_lines[start:end]) else: - text = document.source range = { "start": {"line": 0, "character": 0}, "end": {"line": len(document.lines), "character": 0}, } - config = load_config(document.path, client_config) - - try: - formatted_text = format_text(text=text, config=config) - except black.NothingChanged: - # raised when the file is already formatted correctly - return [] - return [{"range": range, "newText": formatted_text}] -def format_text(*, text, config): +def format_text(*, text, config, lines): mode = black.FileMode( target_versions=config["target_version"], line_length=config["line_length"], @@ -107,7 +112,7 @@ # Will raise black.NothingChanged, we want to bubble that exception up formatted_text = black.format_file_contents( - text, fast=config["fast"], mode=mode + text, fast=config["fast"], mode=mode, lines=lines ) # Restore eols if necessary. @@ -137,8 +142,8 @@ "line_length": settings.get("line_length", 88), "fast": False, "pyi": filename.endswith(".pyi"), - "skip_string_normalization": False, - "skip_magic_trailing_comma": False, + "skip_string_normalization": settings.get("skip_string_normalization", False), + "skip_magic_trailing_comma": settings.get("skip_magic_trailing_comma", False), "target_version": set(), "preview": settings.get("preview", False), } @@ -184,14 +189,6 @@ target_version = set( black.TargetVersion[x.upper()] for x in file_config["target_version"] ) - elif file_config.get("py36"): - target_version = { - black.TargetVersion.PY36, - black.TargetVersion.PY37, - black.TargetVersion.PY38, - black.TargetVersion.PY39, - black.TargetVersion.PY310, - } else: target_version = set() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/pyproject.toml new/python-lsp-black-2.0.0/pyproject.toml --- old/python-lsp-black-1.3.0/pyproject.toml 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/pyproject.toml 2023-12-19 02:48:52.000000000 +0100 @@ -1,5 +1,5 @@ [tool.black] -target-version = ['py36', 'py37', 'py38', 'py39', 'py310'] +target-version = ['py38', 'py39', 'py310', 'py311'] exclude = ''' /( \.venv diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/setup.cfg new/python-lsp-black-2.0.0/setup.cfg --- old/python-lsp-black-1.3.0/setup.cfg 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/setup.cfg 2023-12-19 02:48:52.000000000 +0100 @@ -1,6 +1,6 @@ [metadata] name = python-lsp-black -version = 1.3.0 +version = 2.0.0 author = Python LSP contributors author_email = f...@fidelramos.net description = Black plugin for the Python LSP Server @@ -20,12 +20,12 @@ packages = find: install_requires = python-lsp-server>=1.4.0 - black>=22.3.0 + black>=23.11.0 tomli; python_version<'3.11' -python_requires = >= 3.7 +python_requires = >= 3.8 [options.entry_points] -pylsp = pylsp_black = pylsp_black.plugin +pylsp = black = pylsp_black.plugin [options.extras_require] # add any types-* packages to .pre-commit-config.yaml mypy additional_dependencies diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/tests/fixtures/formatted.txt new/python-lsp-black-2.0.0/tests/fixtures/formatted.txt --- old/python-lsp-black-1.3.0/tests/fixtures/formatted.txt 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/tests/fixtures/formatted.txt 2023-12-19 02:48:52.000000000 +0100 @@ -1,2 +1,15 @@ a = "hello" -b = 42 +b = [ + "a", + "very", + "very", + "very", + "very", + "very", + "very", + "very", + "very", + "long", + "line", +] +c = 42 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/tests/fixtures/py36/pyproject.toml new/python-lsp-black-2.0.0/tests/fixtures/py36/pyproject.toml --- old/python-lsp-black-1.3.0/tests/fixtures/py36/pyproject.toml 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/tests/fixtures/py36/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -[tool.black] -py36 = true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/tests/fixtures/unformatted.txt new/python-lsp-black-2.0.0/tests/fixtures/unformatted.txt --- old/python-lsp-black-1.3.0/tests/fixtures/unformatted.txt 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/tests/fixtures/unformatted.txt 2023-12-19 02:48:52.000000000 +0100 @@ -1,2 +1,3 @@ a = 'hello' -b = 42 +b = ["a", "very", "very", "very", "very", "very", "very", "very", "very", "long", "line"] +c = 42 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-lsp-black-1.3.0/tests/test_plugin.py new/python-lsp-black-2.0.0/tests/test_plugin.py --- old/python-lsp-black-1.3.0/tests/test_plugin.py 2023-05-19 14:15:51.000000000 +0200 +++ new/python-lsp-black-2.0.0/tests/test_plugin.py 2023-12-19 02:48:52.000000000 +0100 @@ -19,6 +19,7 @@ load_config, pylsp_format_document, pylsp_format_range, + pylsp_settings, ) here = Path(__file__).parent @@ -42,23 +43,40 @@ @pytest.fixture +def config_with_skip_options(workspace): + """Return a config object.""" + cfg = Config(workspace.root_uri, {}, 0, {}) + cfg._plugin_settings = { + "plugins": { + "black": { + "line_length": 88, + "cache_config": False, + "skip_string_normalization": True, + "skip_magic_trailing_comma": True, + } + } + } + return cfg + + +@pytest.fixture def unformatted_document(workspace): path = fixtures_dir / "unformatted.txt" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @pytest.fixture def unformatted_pyi_document(workspace): path = fixtures_dir / "unformatted.pyi" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @pytest.fixture def unformatted_crlf_document(workspace): path = fixtures_dir / "unformatted-crlf.py" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa with open(path, "r", newline="") as f: source = f.read() return Document(uri, workspace, source=source) @@ -67,21 +85,21 @@ @pytest.fixture def formatted_document(workspace): path = fixtures_dir / "formatted.txt" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @pytest.fixture def formatted_pyi_document(workspace): path = fixtures_dir / "formatted.pyi" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @pytest.fixture def formatted_crlf_document(workspace): path = fixtures_dir / "formatted-crlf.py" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa with open(path, "r", newline="") as f: source = f.read() return Document(uri, workspace, source=source) @@ -90,28 +108,28 @@ @pytest.fixture def invalid_document(workspace): path = fixtures_dir / "invalid.txt" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @pytest.fixture def config_document(workspace): path = fixtures_dir / "config" / "config.txt" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @pytest.fixture def unformatted_line_length(workspace): path = fixtures_dir / "unformatted-line-length.py" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @pytest.fixture def formatted_line_length(workspace): path = fixtures_dir / "formatted-line-length.py" - uri = f"file:/{path}" + uri = f"file:/{path}" # noqa return Document(uri, workspace) @@ -122,7 +140,7 @@ { "range": { "start": {"line": 0, "character": 0}, - "end": {"line": 2, "character": 0}, + "end": {"line": 3, "character": 0}, }, "newText": formatted_document.source, } @@ -187,7 +205,20 @@ @pytest.mark.parametrize( ("start", "end", "expected"), - [(0, 0, 'a = "hello"\n'), (1, 1, "b = 42\n"), (0, 1, 'a = "hello"\nb = 42\n')], + [ + (0, 0, 'a = "hello"\n'), + ( + 1, + 1, + 'b = [\n "a",\n "very",\n "very",\n "very",\n "very",\n "very",\n "very",\n "very",\n "very",\n "long",\n "line",\n]\n', # noqa: E501 + ), + (2, 2, "c = 42\n"), + ( + 0, + 2, + 'a = "hello"\nb = [\n "a",\n "very",\n "very",\n "very",\n "very",\n "very",\n "very",\n "very",\n "very",\n "long",\n "line",\n]\nc = 42\n', # noqa: E501 + ), + ], ) def test_pylsp_format_range(config, unformatted_document, start, end, expected): range = { @@ -245,18 +276,6 @@ assert config["target_version"] == {black.TargetVersion.PY39} -def test_load_config_py36(config): - config = load_config(str(fixtures_dir / "py36" / "example.py"), config) - - assert config["target_version"] == { - black.TargetVersion.PY36, - black.TargetVersion.PY37, - black.TargetVersion.PY38, - black.TargetVersion.PY39, - black.TargetVersion.PY310, - } - - def test_load_config_defaults(config): config = load_config(str(fixtures_dir / "example.py"), config) @@ -271,9 +290,25 @@ } +def test_load_config_with_skip_options(config_with_skip_options): + config = load_config( + str(fixtures_dir / "skip_options" / "example.py"), config_with_skip_options + ) + + assert config == { + "line_length": 88, + "target_version": set(), + "pyi": False, + "fast": False, + "skip_magic_trailing_comma": True, + "skip_string_normalization": True, + "preview": False, + } + + def test_entry_point(): distribution = pkg_resources.get_distribution("python-lsp-black") - entry_point = distribution.get_entry_info("pylsp", "pylsp_black") + entry_point = distribution.get_entry_info("pylsp", "black") assert entry_point is not None @@ -327,3 +362,13 @@ for _ in range(5): pylsp_format_document(config, unformatted_document) assert _load_config.cache_info().hits == 4 + + +def test_pylsp_settings(config): + plugins = dict(config.plugin_manager.list_name_plugin()) + assert "black" in plugins + assert plugins["black"] not in config.disabled_plugins + config.update({"plugins": {"black": {"enabled": False}}}) + assert plugins["black"] in config.disabled_plugins + config.update(pylsp_settings()) + assert plugins["black"] not in config.disabled_plugins