pytest-revealtype-injector 0.5.0__tar.gz → 0.5.1__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.
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/PKG-INFO +20 -5
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/README.md +19 -4
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/__init__.py +1 -1
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/hooks.py +2 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/.gitignore +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/COPYING +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/COPYING.mit +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/pyproject.toml +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/__init__.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/basedpyright_.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/mypy_.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/pyright_.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/log.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/main.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/models.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/plugin.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/py.typed +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/conftest.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/test_ast_mode.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/test_import.py +0 -0
- {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/test_options.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-revealtype-injector
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity.
|
|
5
5
|
Project-URL: homepage, https://github.com/abelcheung/pytest-revealtype-injector
|
|
6
6
|
Author-email: Abel Cheung <abelcheung@gmail.com>
|
|
@@ -37,7 +37,7 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|
|
|
38
38
|
`pytest-revealtype-injector` is a `pytest` plugin for replacing [`reveal_type()`](https://docs.python.org/3/library/typing.html#typing.reveal_type) calls inside test functions as something more sophisticated. It does the following tasks in parallel:
|
|
39
39
|
|
|
40
|
-
- Launch external static type checkers (`pyright` and `mypy`) and store `reveal_type` results.
|
|
40
|
+
- Launch external static type checkers (`basesdpyright`, `pyright` and `mypy`) and store `reveal_type` results.
|
|
41
41
|
- Use [`typeguard`](https://github.com/agronholm/typeguard) to verify the aforementioned static type checker result _really_ matches runtime code result.
|
|
42
42
|
|
|
43
43
|
## Usage
|
|
@@ -54,7 +54,17 @@ For using `reveal_type()` inside tests, there is no boiler plate code involved.
|
|
|
54
54
|
from typing import reveal_type
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
If you care about compatibility with older pythons, use:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import sys
|
|
61
|
+
if sys.version >= (3, 11):
|
|
62
|
+
from typing import reveal_type
|
|
63
|
+
else:
|
|
64
|
+
from typing_extensions import reveal_type
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Just importing `typing` (or `typing_extensions`) module is fine too:
|
|
58
68
|
|
|
59
69
|
```python
|
|
60
70
|
import typing
|
|
@@ -64,7 +74,7 @@ def test_something():
|
|
|
64
74
|
typing.reveal_type(x) # typeguard fails here
|
|
65
75
|
```
|
|
66
76
|
|
|
67
|
-
Since this plugin scans for `reveal_type()` for replacement under carpet, even `import ... as ...` syntax works
|
|
77
|
+
Since this plugin scans for `reveal_type()` for replacement under carpet, even `import ... as ...` syntax works:
|
|
68
78
|
|
|
69
79
|
```python
|
|
70
80
|
import typing as typ # or...
|
|
@@ -84,7 +94,12 @@ def test_something():
|
|
|
84
94
|
reveal_type(x) # calls vanilla reveal_type()
|
|
85
95
|
```
|
|
86
96
|
|
|
87
|
-
2. `reveal_type()` calls have to stay
|
|
97
|
+
2. `reveal_type()` calls have to stay within a single line, although you can use `reveal_type` result in assertion or other purpose:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
x = "1"
|
|
101
|
+
assert reveal_type(str(int(x))) == x
|
|
102
|
+
```
|
|
88
103
|
|
|
89
104
|
## Logging
|
|
90
105
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
`pytest-revealtype-injector` is a `pytest` plugin for replacing [`reveal_type()`](https://docs.python.org/3/library/typing.html#typing.reveal_type) calls inside test functions as something more sophisticated. It does the following tasks in parallel:
|
|
7
7
|
|
|
8
|
-
- Launch external static type checkers (`pyright` and `mypy`) and store `reveal_type` results.
|
|
8
|
+
- Launch external static type checkers (`basesdpyright`, `pyright` and `mypy`) and store `reveal_type` results.
|
|
9
9
|
- Use [`typeguard`](https://github.com/agronholm/typeguard) to verify the aforementioned static type checker result _really_ matches runtime code result.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -22,7 +22,17 @@ For using `reveal_type()` inside tests, there is no boiler plate code involved.
|
|
|
22
22
|
from typing import reveal_type
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
If you care about compatibility with older pythons, use:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import sys
|
|
29
|
+
if sys.version >= (3, 11):
|
|
30
|
+
from typing import reveal_type
|
|
31
|
+
else:
|
|
32
|
+
from typing_extensions import reveal_type
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Just importing `typing` (or `typing_extensions`) module is fine too:
|
|
26
36
|
|
|
27
37
|
```python
|
|
28
38
|
import typing
|
|
@@ -32,7 +42,7 @@ def test_something():
|
|
|
32
42
|
typing.reveal_type(x) # typeguard fails here
|
|
33
43
|
```
|
|
34
44
|
|
|
35
|
-
Since this plugin scans for `reveal_type()` for replacement under carpet, even `import ... as ...` syntax works
|
|
45
|
+
Since this plugin scans for `reveal_type()` for replacement under carpet, even `import ... as ...` syntax works:
|
|
36
46
|
|
|
37
47
|
```python
|
|
38
48
|
import typing as typ # or...
|
|
@@ -52,7 +62,12 @@ def test_something():
|
|
|
52
62
|
reveal_type(x) # calls vanilla reveal_type()
|
|
53
63
|
```
|
|
54
64
|
|
|
55
|
-
2. `reveal_type()` calls have to stay
|
|
65
|
+
2. `reveal_type()` calls have to stay within a single line, although you can use `reveal_type` result in assertion or other purpose:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
x = "1"
|
|
69
|
+
assert reveal_type(str(int(x))) == x
|
|
70
|
+
```
|
|
56
71
|
|
|
57
72
|
## Logging
|
|
58
73
|
|
|
@@ -54,6 +54,8 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> None:
|
|
|
54
54
|
|
|
55
55
|
def pytest_collection_finish(session: pytest.Session) -> None:
|
|
56
56
|
files = {i.path for i in session.items}
|
|
57
|
+
if not files:
|
|
58
|
+
return
|
|
57
59
|
for adp in session.config.stash[adapter_stash_key]:
|
|
58
60
|
try:
|
|
59
61
|
adp.run_typechecker_on(files)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/test_ast_mode.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|