Skip to content

Commit

Permalink
Fix test failure with black 21.4b0+ (#39)
Browse files Browse the repository at this point in the history
Inline PY36_VERSIONS because black no longer exposes it.

Closes #36.
  • Loading branch information
sveitser committed Jun 4, 2021
1 parent 2ca10aa commit 4a27803
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pyls_black/plugin.py
Expand Up @@ -4,6 +4,8 @@
import toml
from pyls import hookimpl

_PY36_VERSIONS = {black.TargetVersion[v] for v in ["PY36", "PY37", "PY38", "PY39"]}


@hookimpl(tryfirst=True)
def pyls_format_document(document):
Expand Down Expand Up @@ -97,7 +99,7 @@ def load_config(filename: str) -> Dict:
black.TargetVersion[x.upper()] for x in file_config["target_version"]
)
elif file_config.get("py36"):
target_version = black.PY36_VERSIONS
target_version = _PY36_VERSIONS
else:
target_version = set()

Expand Down
9 changes: 7 additions & 2 deletions tests/test_plugin.py
Expand Up @@ -8,7 +8,12 @@
from pyls import uris
from pyls.workspace import Document, Workspace

from pyls_black.plugin import load_config, pyls_format_document, pyls_format_range
from pyls_black.plugin import (
_PY36_VERSIONS,
load_config,
pyls_format_document,
pyls_format_range,
)

here = Path(__file__).parent
fixtures_dir = here / "fixtures"
Expand Down Expand Up @@ -191,7 +196,7 @@ def test_load_config_target_version():
def test_load_config_py36():
config = load_config(str(fixtures_dir / "py36" / "example.py"))

assert config["target_version"] == black.PY36_VERSIONS
assert config["target_version"] == _PY36_VERSIONS


def test_load_config_defaults():
Expand Down

0 comments on commit 4a27803

Please sign in to comment.