rupert/pyls-black

Test failure with black version 21.04b

sveitser opened this issue · 0 comments

When updating black to version 21.04b in nixos ( NixOS/nixpkgs#120684 ) the tests for pyls-black fail (result at the end).

As part of psf/black#1717 PY36_VERSIONS were moved from from src/black/__init__.py to tests/test_black.py.

The corresponding commit is psf/black@6dddbd7 .

============================= test session starts ==============================
platform linux -- Python 3.8.9, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: /build/source
collected 16 items                                                             

tests/test_plugin.py .............F..                                    [100%]

=================================== FAILURES ===================================
____________________________ test_load_config_py36 _____________________________

    def test_load_config_py36():
>       config = load_config(str(fixtures_dir / "py36" / "example.py"))

tests/test_plugin.py:192:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

filename = '/build/source/tests/fixtures/py36/example.py'

    def load_config(filename: str) -> Dict:
        defaults = {
            "line_length": 88,
            "fast": False,
            "pyi": filename.endswith(".pyi"),
            "skip_string_normalization": False,
            "target_version": set(),
        }

        root = black.find_project_root((filename,))

        pyproject_filename = root / "pyproject.toml"

        if not pyproject_filename.is_file():
            return defaults

        try:
            pyproject_toml = toml.load(str(pyproject_filename))
        except (toml.TomlDecodeError, OSError):
            return defaults

        file_config = pyproject_toml.get("tool", {}).get("black", {})
        file_config = {
            key.replace("--", "").replace("-", "_"): value
            for key, value in file_config.items()
        }

        config = {
            key: file_config.get(key, default_value)
            for key, default_value in defaults.items()
        }

        if file_config.get("target_version"):
            target_version = set(
                black.TargetVersion[x.upper()] for x in file_config["target_version"]
            )
        elif file_config.get("py36"):
>           target_version = black.PY36_VERSIONS
E           AttributeError: module 'black' has no attribute 'PY36_VERSIONS'

/nix/store/qqvpg72b33m1pxc5lzjfmx224jp2vrbx-python3.8-pyls-black-0.4.6/lib/python3.8/site-packages/pyls_black/plugin.py:100: AttributeError
=========================== short test summary info ============================
FAILED tests/test_plugin.py::test_load_config_py36 - AttributeError: module '...
========================= 1 failed, 15 passed in 0.66s =========================