typing-protocol-intersection 0.3.4__tar.gz → 0.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/PKG-INFO +2 -2
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/README.md +1 -1
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/setup.cfg +1 -1
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/tests/test_mypy_plugin.py +8 -26
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection/mypy_plugin.py +10 -1
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection.egg-info/PKG-INFO +2 -2
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/LICENSE +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/pyproject.toml +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/tests/test_python_module.py +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection/__init__.py +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection/py.typed +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection/types.py +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection.egg-info/SOURCES.txt +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection.egg-info/dependency_links.txt +0 -0
- {typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/typing_protocol_intersection.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: typing-protocol-intersection
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.7
|
|
4
4
|
Summary: Protocol intersection for mypy
|
|
5
5
|
Home-page: https://github.com/klausweiss/typing-protocol-intersection
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/klausweiss/typing-protocol-intersection/issues
|
|
@@ -31,7 +31,7 @@ See the [examples](#examples) section below.
|
|
|
31
31
|
|
|
32
32
|
## Supported versions
|
|
33
33
|
|
|
34
|
-
The plugin supports python 3.7, 3.8, 3.9, 3.10 and 3.11 and mypy >= 0.920 and <= 1.
|
|
34
|
+
The plugin supports python 3.7, 3.8, 3.9, 3.10 and 3.11 and mypy >= 0.920 and <= 1.5.x.
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
37
37
|
|
|
@@ -12,7 +12,7 @@ See the [examples](#examples) section below.
|
|
|
12
12
|
|
|
13
13
|
## Supported versions
|
|
14
14
|
|
|
15
|
-
The plugin supports python 3.7, 3.8, 3.9, 3.10 and 3.11 and mypy >= 0.920 and <= 1.
|
|
15
|
+
The plugin supports python 3.7, 3.8, 3.9, 3.10 and 3.11 and mypy >= 0.920 and <= 1.5.x.
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
{typing-protocol-intersection-0.3.4 → typing-protocol-intersection-0.3.7}/tests/test_mypy_plugin.py
RENAMED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import typing
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
|
|
4
|
-
import mypy.api
|
|
5
|
-
import mypy.version
|
|
6
4
|
import pytest
|
|
7
5
|
|
|
8
6
|
import typing_protocol_intersection.mypy_plugin
|
|
@@ -45,14 +43,14 @@ def get_expected_stderr(contents: str) -> str:
|
|
|
45
43
|
|
|
46
44
|
|
|
47
45
|
@pytest.fixture()
|
|
48
|
-
def testcase_file(request):
|
|
46
|
+
def testcase_file(request, strip_invisible):
|
|
49
47
|
path = request.param
|
|
50
48
|
with open(HERE / path, encoding="utf-8") as file:
|
|
51
49
|
contents = file.read()
|
|
52
50
|
return _TestCase(
|
|
53
51
|
HERE / path,
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
strip_invisible(get_expected_stdout(contents)),
|
|
53
|
+
strip_invisible(get_expected_stderr(contents)),
|
|
56
54
|
)
|
|
57
55
|
|
|
58
56
|
|
|
@@ -96,35 +94,17 @@ def testcase_file(request):
|
|
|
96
94
|
],
|
|
97
95
|
indirect=["testcase_file"],
|
|
98
96
|
)
|
|
99
|
-
def test_mypy_plugin(testcase_file: _TestCase):
|
|
100
|
-
stdout, stderr =
|
|
97
|
+
def test_mypy_plugin(testcase_file: _TestCase, run_mypy):
|
|
98
|
+
stdout, stderr = run_mypy(testcase_file.path)
|
|
101
99
|
assert (stdout.strip(), stderr.strip()) == (testcase_file.expected_stdout, testcase_file.expected_stderr)
|
|
102
100
|
|
|
103
101
|
|
|
104
|
-
def _run_mypy(input_file: Path) -> typing.Tuple[str, str]:
|
|
105
|
-
stdout, stderr, _ = mypy.api.run(
|
|
106
|
-
[str(input_file), "--config-file", str(HERE / "test-mypy.ini"), "--no-incremental"]
|
|
107
|
-
)
|
|
108
|
-
return _strip(stdout), _strip(stderr)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def _strip(string: str) -> str:
|
|
112
|
-
"""Removes all zero-width spaces from the input text and strips
|
|
113
|
-
whitespaces.
|
|
114
|
-
|
|
115
|
-
The need for the former was born with an ugly hack that we use to
|
|
116
|
-
trick mypyc.
|
|
117
|
-
"""
|
|
118
|
-
zero_width_space = "\u200B"
|
|
119
|
-
return string.strip().replace(zero_width_space, "")
|
|
120
|
-
|
|
121
|
-
|
|
122
102
|
@pytest.mark.parametrize(
|
|
123
103
|
"version",
|
|
124
104
|
[
|
|
125
105
|
pytest.param("0.910", id="0.910 - before the first supported 0.920"),
|
|
126
106
|
pytest.param("0.992", id="0.992 - non-existent version greater than the last tested 0.x"),
|
|
127
|
-
pytest.param("1.
|
|
107
|
+
pytest.param("1.6.0", id="1.6.0 - first greater than 1.5.x with breaking changes"),
|
|
128
108
|
],
|
|
129
109
|
)
|
|
130
110
|
def test_raises_for_unsupported_mypy_versions(version: str) -> None:
|
|
@@ -143,6 +123,8 @@ def test_raises_for_unsupported_mypy_versions(version: str) -> None:
|
|
|
143
123
|
pytest.param("1.2.0", id="1.2.0 - some 1.2.x version"),
|
|
144
124
|
pytest.param("1.3.0", id="1.3.0 - some 1.3.x version"),
|
|
145
125
|
pytest.param("1.4.0", id="1.4.0 - some 1.4.x version"),
|
|
126
|
+
pytest.param("1.5.0", id="1.5.0 - some 1.5.x version"),
|
|
127
|
+
pytest.param("1.5.0", id="1.5.0 - some 1.5.x version"),
|
|
146
128
|
],
|
|
147
129
|
)
|
|
148
130
|
def test_initializes_for_supported_mypy_versions(version: str) -> None:
|
|
@@ -23,6 +23,15 @@ SignatureContext = typing.Union[mypy.plugin.FunctionSigContext, mypy.plugin.Meth
|
|
|
23
23
|
class ProtocolIntersectionPlugin(mypy.plugin.Plugin):
|
|
24
24
|
# pylint: disable=unused-argument
|
|
25
25
|
|
|
26
|
+
def report_config_data(self, ctx: mypy.plugin.ReportConfigContext) -> int:
|
|
27
|
+
# Whatever this method returns is used by mypy to determine whether a module should be checked again or if a
|
|
28
|
+
# cache-loaded info will do. If the obtained value is different from the previous one, cache is invalidated.
|
|
29
|
+
#
|
|
30
|
+
# As far as this plugin is concerned, this method is only used to aid generation of `UniqueFullname`s. If it
|
|
31
|
+
# wasn't for this method, mypy couldn't identify where a runtime-generated class name comes from, as it looks up
|
|
32
|
+
# the class names in the cache (and subsequently crashes when it fails to find them).
|
|
33
|
+
return UniqueFullname.instance_counter
|
|
34
|
+
|
|
26
35
|
def get_type_analyze_hook(
|
|
27
36
|
self, fullname: str
|
|
28
37
|
) -> Optional[Callable[[mypy.plugin.AnalyzeTypeContext], mypy.types.Type]]:
|
|
@@ -193,7 +202,7 @@ def plugin(version: str) -> typing.Type[mypy.plugin.Plugin]:
|
|
|
193
202
|
numeric_prefixes = (_numeric_prefix(x) for x in version_prefix.split("."))
|
|
194
203
|
parted_version = tuple(int(prefix) if prefix else None for prefix in numeric_prefixes)
|
|
195
204
|
if (len(parted_version) == 2 and (0, 920) <= parted_version <= (0, 991)) or (
|
|
196
|
-
len(parted_version) == 3 and (1, 0, 0) <= parted_version < (1,
|
|
205
|
+
len(parted_version) == 3 and (1, 0, 0) <= parted_version < (1, 6, 0)
|
|
197
206
|
):
|
|
198
207
|
return ProtocolIntersectionPlugin
|
|
199
208
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: typing-protocol-intersection
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.7
|
|
4
4
|
Summary: Protocol intersection for mypy
|
|
5
5
|
Home-page: https://github.com/klausweiss/typing-protocol-intersection
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/klausweiss/typing-protocol-intersection/issues
|
|
@@ -31,7 +31,7 @@ See the [examples](#examples) section below.
|
|
|
31
31
|
|
|
32
32
|
## Supported versions
|
|
33
33
|
|
|
34
|
-
The plugin supports python 3.7, 3.8, 3.9, 3.10 and 3.11 and mypy >= 0.920 and <= 1.
|
|
34
|
+
The plugin supports python 3.7, 3.8, 3.9, 3.10 and 3.11 and mypy >= 0.920 and <= 1.5.x.
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
37
37
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|