pytest-revealtype-injector 0.8.0__py3-none-any.whl → 0.9.0__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.
@@ -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.8.0"
3
+ __version__ = "0.9.0"
@@ -110,10 +110,12 @@ class PyreflyAdapter(TypeCheckerAdapter):
110
110
  try:
111
111
  report = json.loads(proc.stdout)
112
112
  except Exception as e:
113
- raise TypeCheckerError(
114
- f"Failed to parse pyrefly JSON output: {e}", None, None
115
- ) from e
116
-
113
+ # pyrefly (circa 0.47.0) appends github text formatted annotation at the end of json output
114
+ decoder = json.JSONDecoder()
115
+ report, _ = decoder.raw_decode(proc.stdout.decode())
116
+ _logger.warning(
117
+ f"({self.id}) failed to parse json output, extracted partial json: {e}"
118
+ )
117
119
  assert isinstance(report, dict) and "errors" in report
118
120
  items = cast(list[_PyreflyDiagItem], report["errors"])
119
121
 
@@ -63,7 +63,7 @@ class NameCollector(BareNameCollector):
63
63
  class TyAdapter(TypeCheckerAdapter):
64
64
  id = "ty"
65
65
  _executable = "ty"
66
- _type_mesg_re = re.compile(r'Revealed type: `(?P<type>.+?)`')
66
+ _type_mesg_re = re.compile(r"Revealed type: `(?P<type>.+?)`")
67
67
  _namecollector_class = BareNameCollector
68
68
  _schema = s.Schema({
69
69
  "check_name": str,
@@ -78,8 +78,8 @@ class TyAdapter(TypeCheckerAdapter):
78
78
  "path": str,
79
79
  "positions": {
80
80
  "begin": {"line": int, "column": int},
81
- "end" : {"line": int, "column": int},
82
- }
81
+ "end": {"line": int, "column": int},
82
+ },
83
83
  },
84
84
  })
85
85
 
@@ -152,11 +152,12 @@ class TyAdapter(TypeCheckerAdapter):
152
152
  filename, lineno = (
153
153
  pathlib.Path(diag["location"]["path"]).name,
154
154
  diag["location"]["positions"]["begin"]["line"],
155
- )
155
+ )
156
156
  if (m := self._type_mesg_re.search(diag["description"])) is None:
157
157
  continue
158
158
  pos = FilePos(filename, lineno)
159
159
  self.typechecker_result[pos] = VarType(None, ForwardRef(m["type"]))
160
160
 
161
+
161
162
  def generate_adapter() -> TypeCheckerAdapter:
162
- return TyAdapter()
163
+ return TyAdapter()
@@ -49,7 +49,7 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> Iterator[None]:
49
49
  adapters = {a for a in adp_stash}
50
50
 
51
51
  if not adapters:
52
- pytest.fail("No type checker is enabled.")
52
+ pytest.skip("No type checker is enabled for this test.")
53
53
 
54
54
  # Monkeypatch reveal_type() with our own function, to guarantee
55
55
  # each test func can receive different adapters
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-revealtype-injector
3
- Version: 0.8.0
3
+ Version: 0.9.0
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>
@@ -1,5 +1,5 @@
1
- pytest_revealtype_injector/__init__.py,sha256=Ph1EXPASRvuYCAS50jr7ujTT5qdEzD2lco0ygFyIf0E,211
2
- pytest_revealtype_injector/hooks.py,sha256=7eHjIdD_PCXr9Wwtjlnmgk7QrSui1dQJVGKmCkGo9JQ,5907
1
+ pytest_revealtype_injector/__init__.py,sha256=xHdhFMEZ-16-efdImbsnZ6DlyFmSEs_AIKuo54vGvCI,211
2
+ pytest_revealtype_injector/hooks.py,sha256=byWwZNiujxcKJra8cFfEfc51MRJmXIsECoAGMR8d9oA,5921
3
3
  pytest_revealtype_injector/log.py,sha256=Ptd3yp1H1GlUum6BAwHc9cdyeGmaY8XYf0jp6qJmG4M,418
4
4
  pytest_revealtype_injector/main.py,sha256=vXRtZ3ITY2FcUMzA4MFTXeOR33-qn0uTP1XNgaHP7ro,5771
5
5
  pytest_revealtype_injector/models.py,sha256=_Dpi4Y8rkThh8zIAf2RAzdF7sv0ldUnKdYMcp9IhPFA,6245
@@ -8,11 +8,11 @@ pytest_revealtype_injector/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
8
8
  pytest_revealtype_injector/adapter/__init__.py,sha256=8RvzccYXKBjj3718Io8_lqiL35O5mfHprKobwO8ioPI,762
9
9
  pytest_revealtype_injector/adapter/basedpyright_.py,sha256=8LX7GmJmg4OZ3LKO5WoQ7Ocub6Lxi3HTStIorMApzUA,466
10
10
  pytest_revealtype_injector/adapter/mypy_.py,sha256=NJAY5UGxVLoCznp1XRzaYG1eybI6URCbfvqzhO7GHpA,9427
11
- pytest_revealtype_injector/adapter/pyrefly_.py,sha256=3hVznpIuHaTGqnkWjNa_t_Kigy33AnFam7AmiYgtp5Y,4396
11
+ pytest_revealtype_injector/adapter/pyrefly_.py,sha256=c-n1R_5rseAI6xrdXrfZ8-_0vqlYhY0j7WORjJEnUdo,4607
12
12
  pytest_revealtype_injector/adapter/pyright_.py,sha256=Zz8RDlmpeUySH0xNnfn5K4PzrTxERtAuerdCqvRJwmU,4197
13
- pytest_revealtype_injector/adapter/ty_.py,sha256=fRkIj-xi0KzeJtP_RfmWIrNFFDDDH66mzV7OzuhXnUg,4658
14
- pytest_revealtype_injector-0.8.0.dist-info/METADATA,sha256=LUOruluwG01O2Lc_tSCOC3-Fa7CKy2xKpDIizbHR5hI,7574
15
- pytest_revealtype_injector-0.8.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
16
- pytest_revealtype_injector-0.8.0.dist-info/entry_points.txt,sha256=UfOm7y3WQnOoGV1mgTMb42MI6iBRPIl88FJiAOnt6SY,74
17
- pytest_revealtype_injector-0.8.0.dist-info/licenses/COPYING.mit,sha256=IzYEFDIOECyuupg_B3O9FvgjnU9i4JtambpbleoYHdQ,1060
18
- pytest_revealtype_injector-0.8.0.dist-info/RECORD,,
13
+ pytest_revealtype_injector/adapter/ty_.py,sha256=wErCzMqFHNbKSUzfc_Wc3U_8lYNgYSxsa4YgFZDEBGI,4647
14
+ pytest_revealtype_injector-0.9.0.dist-info/METADATA,sha256=EyYLEM2SWB5Og8EebKzRW7LuikseiPYbk0CcGWXeQxI,7574
15
+ pytest_revealtype_injector-0.9.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
16
+ pytest_revealtype_injector-0.9.0.dist-info/entry_points.txt,sha256=UfOm7y3WQnOoGV1mgTMb42MI6iBRPIl88FJiAOnt6SY,74
17
+ pytest_revealtype_injector-0.9.0.dist-info/licenses/COPYING.mit,sha256=IzYEFDIOECyuupg_B3O9FvgjnU9i4JtambpbleoYHdQ,1060
18
+ pytest_revealtype_injector-0.9.0.dist-info/RECORD,,