pytest-revealtype-injector 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.whl
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/__init__.py +1 -1
- pytest_revealtype_injector/adapter/mypy_.py +24 -6
- {pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/METADATA +1 -1
- {pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/RECORD +8 -8
- {pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/WHEEL +0 -0
- {pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/entry_points.txt +0 -0
- {pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/licenses/COPYING +0 -0
- {pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/licenses/COPYING.mit +0 -0
|
@@ -125,6 +125,10 @@ class NameCollector(NameCollectorBase):
|
|
|
125
125
|
# something like "test_elem_class_lookup.FooClass@97".
|
|
126
126
|
# Return only the left operand after processing.
|
|
127
127
|
def visit_BinOp(self, node: ast.BinOp) -> ast.expr:
|
|
128
|
+
if isinstance(node.op, ast.BitOr): # union
|
|
129
|
+
node.left = self.visit(node.left)
|
|
130
|
+
node.right = self.visit(node.right)
|
|
131
|
+
return node
|
|
128
132
|
if isinstance(node.op, ast.MatMult) and isinstance(node.right, ast.Constant):
|
|
129
133
|
return cast("ast.expr", self.visit(node.left))
|
|
130
134
|
# For expression that haven't been accounted for, just don't
|
|
@@ -132,6 +136,25 @@ class NameCollector(NameCollectorBase):
|
|
|
132
136
|
return node
|
|
133
137
|
|
|
134
138
|
|
|
139
|
+
# Mypy can insert extra character into expression so that it
|
|
140
|
+
# becomes invalid and unparsable. 0.9x days there
|
|
141
|
+
# was '*', and now '?' (and '=' for typeddict too).
|
|
142
|
+
# Instead of globally throwing them away (and causing
|
|
143
|
+
# literal string constants to not match), we iteratively
|
|
144
|
+
# remove chars one by one only where parsing error occurs.
|
|
145
|
+
#
|
|
146
|
+
def _strip_unwanted_char(input: str) -> str:
|
|
147
|
+
result = input
|
|
148
|
+
while True:
|
|
149
|
+
try:
|
|
150
|
+
_ = ast.parse(result)
|
|
151
|
+
except SyntaxError as e:
|
|
152
|
+
assert e.offset is not None
|
|
153
|
+
result = result[:e.offset-1] + result[e.offset:]
|
|
154
|
+
else:
|
|
155
|
+
return result
|
|
156
|
+
|
|
157
|
+
|
|
135
158
|
class MypyAdapter(TypeCheckerAdapter):
|
|
136
159
|
id = "mypy"
|
|
137
160
|
_executable = "" # unused, calls mypy.api.run() here
|
|
@@ -208,12 +231,7 @@ class MypyAdapter(TypeCheckerAdapter):
|
|
|
208
231
|
)
|
|
209
232
|
if (m := self._type_mesg_re.fullmatch(diag["message"])) is None:
|
|
210
233
|
continue
|
|
211
|
-
|
|
212
|
-
# becomes invalid and unparsable. 0.9x days there
|
|
213
|
-
# was '*', and now '?' (and '=' for typeddict too).
|
|
214
|
-
# Try stripping those character and pray we get something
|
|
215
|
-
# usable for evaluation
|
|
216
|
-
expression = m["type"].translate({ord(c): None for c in "*?="})
|
|
234
|
+
expression = _strip_unwanted_char(m["type"])
|
|
217
235
|
try:
|
|
218
236
|
# Unlike pyright, mypy output doesn't contain variable name
|
|
219
237
|
self.typechecker_result[pos] = VarType(None, ForwardRef(expression))
|
{pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-revealtype-injector
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
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>
|
{pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/RECORD
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pytest_revealtype_injector/__init__.py,sha256=
|
|
1
|
+
pytest_revealtype_injector/__init__.py,sha256=aiBTdl1GqqEAFu1nrAFIExIe_G2uGgrFYltHSNLKUXo,211
|
|
2
2
|
pytest_revealtype_injector/hooks.py,sha256=_yJD6htagRJGElrSucFbDxSHT_osdoD9Lx3P4N5sjhM,4465
|
|
3
3
|
pytest_revealtype_injector/log.py,sha256=Ptd3yp1H1GlUum6BAwHc9cdyeGmaY8XYf0jp6qJmG4M,418
|
|
4
4
|
pytest_revealtype_injector/main.py,sha256=3w-_CoZHTrBSC-5iX0cYMsW5rzdmmsqIwcw39x4E0EQ,5656
|
|
@@ -7,11 +7,11 @@ pytest_revealtype_injector/plugin.py,sha256=fkI6yF0dFVba0jEikIrsRp1NUQd2ohWLq4x2
|
|
|
7
7
|
pytest_revealtype_injector/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
pytest_revealtype_injector/adapter/__init__.py,sha256=FRVB1eUrXaMzdQG0wRdIEKhx2dzGdyJcHDBb3eTTeOY,602
|
|
9
9
|
pytest_revealtype_injector/adapter/basedpyright_.py,sha256=8LX7GmJmg4OZ3LKO5WoQ7Ocub6Lxi3HTStIorMApzUA,466
|
|
10
|
-
pytest_revealtype_injector/adapter/mypy_.py,sha256=
|
|
10
|
+
pytest_revealtype_injector/adapter/mypy_.py,sha256=A8Uw21qm-BRMED1HiQ13McMn8jQCVTTZDnNM2inzkBE,9314
|
|
11
11
|
pytest_revealtype_injector/adapter/pyright_.py,sha256=j9121YxGeulZpRRJAO0dLFpaoTjE6t343-qS-O952QU,5122
|
|
12
|
-
pytest_revealtype_injector-0.6.
|
|
13
|
-
pytest_revealtype_injector-0.6.
|
|
14
|
-
pytest_revealtype_injector-0.6.
|
|
15
|
-
pytest_revealtype_injector-0.6.
|
|
16
|
-
pytest_revealtype_injector-0.6.
|
|
17
|
-
pytest_revealtype_injector-0.6.
|
|
12
|
+
pytest_revealtype_injector-0.6.2.dist-info/METADATA,sha256=CgwPmLecZ0bP_Zji97wP8lxccjtPPU3o6Y_xsoBORg0,6729
|
|
13
|
+
pytest_revealtype_injector-0.6.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
pytest_revealtype_injector-0.6.2.dist-info/entry_points.txt,sha256=UfOm7y3WQnOoGV1mgTMb42MI6iBRPIl88FJiAOnt6SY,74
|
|
15
|
+
pytest_revealtype_injector-0.6.2.dist-info/licenses/COPYING,sha256=LSYUX8PcSMvHCkhM5oi07eOrSLV89qdEJ-FVZmbcpNE,355
|
|
16
|
+
pytest_revealtype_injector-0.6.2.dist-info/licenses/COPYING.mit,sha256=IzYEFDIOECyuupg_B3O9FvgjnU9i4JtambpbleoYHdQ,1060
|
|
17
|
+
pytest_revealtype_injector-0.6.2.dist-info/RECORD,,
|
{pytest_revealtype_injector-0.6.0.dist-info → pytest_revealtype_injector-0.6.2.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|