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.
Files changed (21) hide show
  1. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/PKG-INFO +20 -5
  2. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/README.md +19 -4
  3. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/__init__.py +1 -1
  4. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/hooks.py +2 -0
  5. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/.gitignore +0 -0
  6. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/COPYING +0 -0
  7. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/COPYING.mit +0 -0
  8. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/pyproject.toml +0 -0
  9. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/__init__.py +0 -0
  10. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/basedpyright_.py +0 -0
  11. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/mypy_.py +0 -0
  12. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/adapter/pyright_.py +0 -0
  13. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/log.py +0 -0
  14. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/main.py +0 -0
  15. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/models.py +0 -0
  16. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/plugin.py +0 -0
  17. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/src/pytest_revealtype_injector/py.typed +0 -0
  18. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/conftest.py +0 -0
  19. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/test_ast_mode.py +0 -0
  20. {pytest_revealtype_injector-0.5.0 → pytest_revealtype_injector-0.5.1}/tests/test_import.py +0 -0
  21. {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.0
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
- Just importing `typing` module is fine too (or import `typing_extensions` for Python 3.10, because `reveal_type()` is only available officially since 3.11):
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 too:
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 in a single line, without anything else. This limitation comes from using [`eval` mode in AST parsing](https://docs.python.org/3/library/ast.html#ast.Expression).
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
- Just importing `typing` module is fine too (or import `typing_extensions` for Python 3.10, because `reveal_type()` is only available officially since 3.11):
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 too:
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 in a single line, without anything else. This limitation comes from using [`eval` mode in AST parsing](https://docs.python.org/3/library/ast.html#ast.Expression).
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
 
@@ -1,3 +1,3 @@
1
1
  """Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity.""" # noqa: E501
2
2
 
3
- __version__ = "0.5.0"
3
+ __version__ = "0.5.1"
@@ -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)