Skip to content

Commit c1437e8

Browse files
committed
Add Python 3.8 support for rope_implementations
1 parent 9c715d1 commit c1437e8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pylsp/plugins/rope_implementation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2021- Python Language Server Contributors.
33
import logging
44
import os
5-
from typing import Any
5+
from typing import Any, Dict, Tuple
66

77
from rope.base.project import Project
88
from rope.base.resources import Resource
@@ -42,7 +42,7 @@ def pylsp_implementations(config, workspace, document, position):
4242

4343
def _rope_location_to_range(
4444
location: Location, rope_project: Project
45-
) -> dict[str, Any]:
45+
) -> Dict[str, Any]:
4646
# NOTE: This assumes the result is confined to a single line, which should
4747
# always be the case here because Python doesn't allow splitting up
4848
# identifiers across more than one line.
@@ -56,8 +56,8 @@ def _rope_location_to_range(
5656

5757

5858
def _rope_region_to_columns(
59-
offsets: tuple[int, int], line: int, rope_resource: Resource, rope_project: Project
60-
) -> tuple[int, int]:
59+
offsets: Tuple[int, int], line: int, rope_resource: Resource, rope_project: Project
60+
) -> Tuple[int, int]:
6161
"""
6262
Convert pair of offsets from start of file to columns within line.
6363

test/plugins/test_implementations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright 2017-2020 Palantir Technologies, Inc.
22
# Copyright 2021- Python Language Server Contributors.
33

4-
from collections.abc import Iterable
5-
from importlib.resources import as_file, files
4+
import test
65
from pathlib import Path
76

87
import pytest
@@ -21,9 +20,10 @@
2120
# An alternative to using real files would be `unittest.mock.patch`, but that
2221
# ends up being more trouble than it's worth...
2322
@pytest.fixture
24-
def examples_dir_path() -> Iterable[Path]:
25-
with as_file(files("test.data.implementations_examples")) as path:
26-
yield path
23+
def examples_dir_path() -> Path:
24+
# In Python 3.12+, this should be obtained using `importlib.resources`,
25+
# but as we need to support older versions, we do it the hacky way:
26+
return Path(test.__file__).parent / "data/implementations_examples"
2727

2828

2929
@pytest.fixture

0 commit comments

Comments
 (0)