jaclang 0.4.7__py3-none-any.whl → 0.5.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.

Potentially problematic release.


This version of jaclang might be problematic. Click here for more details.

Files changed (152) hide show
  1. jaclang/__init__.py +5 -2
  2. jaclang/cli/cli.py +56 -8
  3. jaclang/cli/cmdreg.py +16 -9
  4. jaclang/compiler/__jac_gen__/jac_parser.py +11 -15
  5. jaclang/compiler/absyntree.py +53 -19
  6. jaclang/compiler/codeloc.py +3 -1
  7. jaclang/compiler/{transpiler.py → compile.py} +3 -2
  8. jaclang/compiler/constant.py +4 -0
  9. jaclang/compiler/parser.py +156 -108
  10. jaclang/compiler/passes/ir_pass.py +1 -0
  11. jaclang/compiler/passes/main/__init__.py +2 -1
  12. jaclang/compiler/passes/main/def_impl_match_pass.py +1 -0
  13. jaclang/compiler/passes/main/def_use_pass.py +1 -0
  14. jaclang/compiler/passes/main/import_pass.py +18 -18
  15. jaclang/compiler/passes/main/pyast_gen_pass.py +1228 -853
  16. jaclang/compiler/passes/main/pyast_load_pass.py +3 -1
  17. jaclang/compiler/passes/main/pybc_gen_pass.py +46 -0
  18. jaclang/compiler/passes/main/pyout_pass.py +6 -7
  19. jaclang/compiler/passes/main/schedules.py +5 -9
  20. jaclang/compiler/passes/main/sub_node_tab_pass.py +1 -0
  21. jaclang/compiler/passes/main/sym_tab_build_pass.py +21 -9
  22. jaclang/compiler/passes/main/tests/test_decl_def_match_pass.py +2 -1
  23. jaclang/compiler/passes/main/tests/test_def_use_pass.py +2 -1
  24. jaclang/compiler/passes/main/tests/test_import_pass.py +2 -1
  25. jaclang/compiler/passes/main/tests/test_pyast_build_pass.py +1 -0
  26. jaclang/compiler/passes/main/tests/test_pyast_gen_pass.py +15 -38
  27. jaclang/compiler/passes/main/tests/test_pybc_gen_pass.py +25 -0
  28. jaclang/compiler/passes/main/tests/test_sub_node_pass.py +1 -1
  29. jaclang/compiler/passes/main/tests/test_sym_tab_build_pass.py +2 -1
  30. jaclang/compiler/passes/main/tests/test_type_check_pass.py +17 -1
  31. jaclang/compiler/passes/main/type_check_pass.py +9 -6
  32. jaclang/compiler/passes/tool/__init__.py +1 -0
  33. jaclang/compiler/passes/tool/ast_printer_pass.py +1 -0
  34. jaclang/compiler/passes/tool/fuse_comments_pass.py +1 -1
  35. jaclang/compiler/passes/tool/jac_formatter_pass.py +69 -32
  36. jaclang/compiler/passes/tool/schedules.py +1 -0
  37. jaclang/compiler/passes/tool/sym_tab_printer_pass.py +1 -0
  38. jaclang/compiler/passes/tool/tests/test_ast_print_pass.py +2 -1
  39. jaclang/compiler/passes/tool/tests/test_fuse_comments_pass.py +1 -0
  40. jaclang/compiler/passes/tool/tests/test_jac_format_pass.py +4 -3
  41. jaclang/compiler/passes/tool/tests/test_symtab_print_pass.py +2 -1
  42. jaclang/compiler/passes/transform.py +1 -0
  43. jaclang/compiler/passes/utils/mypy_ast_build.py +203 -17
  44. jaclang/compiler/symtable.py +1 -0
  45. jaclang/compiler/tests/test_importer.py +3 -2
  46. jaclang/compiler/tests/test_parser.py +1 -0
  47. jaclang/compiler/tests/test_workspace.py +1 -0
  48. jaclang/compiler/workspace.py +18 -5
  49. jaclang/core/construct.py +9 -32
  50. jaclang/{compiler → core}/importer.py +95 -85
  51. jaclang/core/utils.py +17 -12
  52. jaclang/plugin/__init__.py +1 -0
  53. jaclang/plugin/default.py +145 -43
  54. jaclang/plugin/feature.py +65 -19
  55. jaclang/plugin/spec.py +56 -34
  56. jaclang/plugin/tests/test_features.py +9 -0
  57. jaclang/utils/helpers.py +1 -0
  58. jaclang/utils/lang_tools.py +13 -19
  59. jaclang/utils/tests/test_lang_tools.py +2 -1
  60. jaclang/utils/treeprinter.py +2 -1
  61. jaclang/vendor/lark/common.py +3 -1
  62. jaclang/vendor/lark/lexer.py +6 -12
  63. jaclang/vendor/lark/parsers/lalr_parser.py +1 -0
  64. jaclang/vendor/mypy/applytype.py +2 -1
  65. jaclang/vendor/mypy/binder.py +1 -1
  66. jaclang/vendor/mypy/build.py +7 -9
  67. jaclang/vendor/mypy/checker.py +57 -33
  68. jaclang/vendor/mypy/checkexpr.py +42 -29
  69. jaclang/vendor/mypy/checkmember.py +13 -1
  70. jaclang/vendor/mypy/checkpattern.py +1 -1
  71. jaclang/vendor/mypy/checkstrformat.py +2 -4
  72. jaclang/vendor/mypy/constraints.py +10 -5
  73. jaclang/vendor/mypy/dmypy_server.py +3 -3
  74. jaclang/vendor/mypy/dmypy_util.py +62 -3
  75. jaclang/vendor/mypy/errors.py +1 -1
  76. jaclang/vendor/mypy/evalexpr.py +1 -0
  77. jaclang/vendor/mypy/expandtype.py +29 -29
  78. jaclang/vendor/mypy/fastparse.py +51 -31
  79. jaclang/vendor/mypy/inspections.py +5 -3
  80. jaclang/vendor/mypy/join.py +4 -4
  81. jaclang/vendor/mypy/main.py +6 -6
  82. jaclang/vendor/mypy/message_registry.py +1 -2
  83. jaclang/vendor/mypy/messages.py +31 -23
  84. jaclang/vendor/mypy/metastore.py +1 -2
  85. jaclang/vendor/mypy/modulefinder.py +2 -22
  86. jaclang/vendor/mypy/nodes.py +22 -20
  87. jaclang/vendor/mypy/options.py +4 -0
  88. jaclang/vendor/mypy/parse.py +6 -2
  89. jaclang/vendor/mypy/patterns.py +6 -6
  90. jaclang/vendor/mypy/plugin.py +3 -1
  91. jaclang/vendor/mypy/plugins/attrs.py +52 -10
  92. jaclang/vendor/mypy/plugins/common.py +2 -1
  93. jaclang/vendor/mypy/plugins/enums.py +3 -2
  94. jaclang/vendor/mypy/plugins/functools.py +1 -0
  95. jaclang/vendor/mypy/renaming.py +1 -1
  96. jaclang/vendor/mypy/report.py +15 -15
  97. jaclang/vendor/mypy/semanal.py +22 -13
  98. jaclang/vendor/mypy/semanal_enum.py +1 -1
  99. jaclang/vendor/mypy/semanal_namedtuple.py +1 -2
  100. jaclang/vendor/mypy/semanal_shared.py +3 -6
  101. jaclang/vendor/mypy/semanal_typeddict.py +16 -5
  102. jaclang/vendor/mypy/server/astdiff.py +15 -9
  103. jaclang/vendor/mypy/server/astmerge.py +5 -5
  104. jaclang/vendor/mypy/stats.py +0 -5
  105. jaclang/vendor/mypy/stubdoc.py +1 -1
  106. jaclang/vendor/mypy/stubgen.py +12 -21
  107. jaclang/vendor/mypy/stubgenc.py +16 -8
  108. jaclang/vendor/mypy/stubtest.py +57 -48
  109. jaclang/vendor/mypy/stubutil.py +28 -15
  110. jaclang/vendor/mypy/subtypes.py +4 -4
  111. jaclang/vendor/mypy/test/helpers.py +2 -2
  112. jaclang/vendor/mypy/test/meta/test_parse_data.py +1 -0
  113. jaclang/vendor/mypy/test/meta/test_update_data.py +1 -0
  114. jaclang/vendor/mypy/test/testargs.py +1 -0
  115. jaclang/vendor/mypy/test/testcheck.py +4 -1
  116. jaclang/vendor/mypy/test/testconstraints.py +25 -7
  117. jaclang/vendor/mypy/test/testerrorstream.py +1 -0
  118. jaclang/vendor/mypy/test/testformatter.py +2 -2
  119. jaclang/vendor/mypy/test/testparse.py +6 -4
  120. jaclang/vendor/mypy/test/testpythoneval.py +1 -0
  121. jaclang/vendor/mypy/test/testreports.py +1 -0
  122. jaclang/vendor/mypy/test/teststubgen.py +1 -2
  123. jaclang/vendor/mypy/test/teststubtest.py +98 -4
  124. jaclang/vendor/mypy/test/testtypes.py +1 -1
  125. jaclang/vendor/mypy/test/testutil.py +22 -0
  126. jaclang/vendor/mypy/typeanal.py +302 -158
  127. jaclang/vendor/mypy/typeops.py +22 -13
  128. jaclang/vendor/mypy/types.py +33 -34
  129. jaclang/vendor/mypy/typestate.py +2 -2
  130. jaclang/vendor/mypy/util.py +7 -6
  131. jaclang/vendor/mypy/version.py +1 -1
  132. jaclang/vendor/mypyc/analysis/ircheck.py +1 -0
  133. jaclang/vendor/mypyc/codegen/emitfunc.py +5 -3
  134. jaclang/vendor/mypyc/codegen/emitmodule.py +12 -12
  135. jaclang/vendor/mypyc/codegen/emitwrapper.py +2 -2
  136. jaclang/vendor/mypyc/ir/class_ir.py +10 -6
  137. jaclang/vendor/mypyc/irbuild/builder.py +3 -4
  138. jaclang/vendor/mypyc/irbuild/function.py +5 -3
  139. jaclang/vendor/mypyc/irbuild/nonlocalcontrol.py +1 -2
  140. jaclang/vendor/mypyc/irbuild/prepare.py +6 -6
  141. jaclang/vendor/mypyc/primitives/registry.py +15 -5
  142. jaclang/vendor/mypyc/test/test_run.py +1 -2
  143. jaclang/vendor/mypyc/transform/uninit.py +3 -3
  144. jaclang/vendor/pluggy/_callers.py +1 -0
  145. jaclang/vendor/pluggy/_hooks.py +6 -10
  146. jaclang/vendor/pluggy/_result.py +1 -0
  147. jaclang/vendor/pluggy/_tracing.py +1 -0
  148. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/METADATA +1 -1
  149. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/RECORD +152 -150
  150. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/WHEEL +0 -0
  151. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/entry_points.txt +0 -0
  152. {jaclang-0.4.7.dist-info → jaclang-0.5.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  """Test cases for reports generated by mypy."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import textwrap
@@ -1213,8 +1213,7 @@ class StubgencSuite(unittest.TestCase):
1213
1213
  assert_equal(gen.get_imports().splitlines(), ["import foo", "import other"])
1214
1214
 
1215
1215
  def test_generate_c_function_no_crash_for_non_str_docstring(self) -> None:
1216
- def test(arg0: str) -> None:
1217
- ...
1216
+ def test(arg0: str) -> None: ...
1218
1217
 
1219
1218
  test.__doc__ = property(lambda self: "test(arg0: str) -> None") # type: ignore[assignment]
1220
1219
 
@@ -177,7 +177,7 @@ def run_stubtest(
177
177
 
178
178
 
179
179
  class Case:
180
- def __init__(self, stub: str, runtime: str, error: str | None):
180
+ def __init__(self, stub: str, runtime: str, error: str | None) -> None:
181
181
  self.stub = stub
182
182
  self.runtime = runtime
183
183
  self.error = error
@@ -214,7 +214,15 @@ def collect_cases(fn: Callable[..., Iterator[Case]]) -> Callable[..., None]:
214
214
  )
215
215
 
216
216
  actual_errors = set(output.splitlines())
217
- assert actual_errors == expected_errors, output
217
+ if actual_errors != expected_errors:
218
+ output = run_stubtest(
219
+ stub="\n\n".join(textwrap.dedent(c.stub.lstrip("\n")) for c in cases),
220
+ runtime="\n\n".join(
221
+ textwrap.dedent(c.runtime.lstrip("\n")) for c in cases
222
+ ),
223
+ options=[],
224
+ )
225
+ assert actual_errors == expected_errors, output
218
226
 
219
227
  return test
220
228
 
@@ -712,6 +720,56 @@ class StubtestUnit(unittest.TestCase):
712
720
  """,
713
721
  error=None,
714
722
  )
723
+ yield Case(
724
+ stub="""
725
+ @overload
726
+ def f7(a: int, /) -> int: ...
727
+ @overload
728
+ def f7(b: str, /) -> str: ...
729
+ """,
730
+ runtime="def f7(x, /): pass",
731
+ error=None,
732
+ )
733
+ yield Case(
734
+ stub="""
735
+ @overload
736
+ def f8(a: int, c: int = 0, /) -> int: ...
737
+ @overload
738
+ def f8(b: str, d: int, /) -> str: ...
739
+ """,
740
+ runtime="def f8(x, y, /): pass",
741
+ error="f8",
742
+ )
743
+ yield Case(
744
+ stub="""
745
+ @overload
746
+ def f9(a: int, c: int = 0, /) -> int: ...
747
+ @overload
748
+ def f9(b: str, d: int, /) -> str: ...
749
+ """,
750
+ runtime="def f9(x, y=0, /): pass",
751
+ error=None,
752
+ )
753
+ yield Case(
754
+ stub="""
755
+ class Bar:
756
+ @overload
757
+ def f1(self) -> int: ...
758
+ @overload
759
+ def f1(self, a: int, /) -> int: ...
760
+
761
+ @overload
762
+ def f2(self, a: int, /) -> int: ...
763
+ @overload
764
+ def f2(self, a: str, /) -> int: ...
765
+ """,
766
+ runtime="""
767
+ class Bar:
768
+ def f1(self, *a) -> int: ...
769
+ def f2(self, *a) -> int: ...
770
+ """,
771
+ error=None,
772
+ )
715
773
 
716
774
  @collect_cases
717
775
  def test_property(self) -> Iterator[Case]:
@@ -1139,6 +1197,25 @@ class StubtestUnit(unittest.TestCase):
1139
1197
  """,
1140
1198
  error=None,
1141
1199
  )
1200
+ yield Case(
1201
+ runtime="""
1202
+ import enum
1203
+ class SomeObject: ...
1204
+
1205
+ class WeirdEnum(enum.Enum):
1206
+ a = SomeObject()
1207
+ b = SomeObject()
1208
+ """,
1209
+ stub="""
1210
+ import enum
1211
+ class SomeObject: ...
1212
+ class WeirdEnum(enum.Enum):
1213
+ _value_: SomeObject
1214
+ a = ...
1215
+ b = ...
1216
+ """,
1217
+ error=None,
1218
+ )
1142
1219
  yield Case(
1143
1220
  stub="""
1144
1221
  class Flags4(enum.Flag):
@@ -1270,6 +1347,24 @@ class StubtestUnit(unittest.TestCase):
1270
1347
  yield Case(stub="", runtime="from json.scanner import NUMBER_RE", error=None)
1271
1348
  yield Case(stub="", runtime="from string import ascii_letters", error=None)
1272
1349
 
1350
+ @collect_cases
1351
+ def test_missing_no_runtime_all_terrible(self) -> Iterator[Case]:
1352
+ yield Case(
1353
+ stub="",
1354
+ runtime="""
1355
+ import sys
1356
+ import types
1357
+ import __future__
1358
+ _m = types.SimpleNamespace()
1359
+ _m.annotations = __future__.annotations
1360
+ sys.modules["_terrible_stubtest_test_module"] = _m
1361
+
1362
+ from _terrible_stubtest_test_module import *
1363
+ assert annotations
1364
+ """,
1365
+ error=None,
1366
+ )
1367
+
1273
1368
  @collect_cases
1274
1369
  def test_non_public_1(self) -> Iterator[Case]:
1275
1370
  yield Case(
@@ -2330,8 +2425,7 @@ class StubtestMiscUnit(unittest.TestCase):
2330
2425
  options=["--allowlist", allowlist.name, "--generate-allowlist"],
2331
2426
  )
2332
2427
  assert output == (
2333
- f"note: unused allowlist entry unused.*\n"
2334
- f"{TEST_MODULE_NAME}.also_bad\n"
2428
+ f"note: unused allowlist entry unused.*\n{TEST_MODULE_NAME}.also_bad\n"
2335
2429
  )
2336
2430
  finally:
2337
2431
  os.unlink(allowlist.name)
@@ -1717,7 +1717,7 @@ def make_call(*items: tuple[str, str | None]) -> CallExpr:
1717
1717
  class TestExpandTypeLimitGetProperType(TestCase):
1718
1718
  # WARNING: do not increase this number unless absolutely necessary,
1719
1719
  # and you understand what you are doing.
1720
- ALLOWED_GET_PROPER_TYPES = 8
1720
+ ALLOWED_GET_PROPER_TYPES = 9
1721
1721
 
1722
1722
  @skipUnless(mypy.expandtype.__file__.endswith(".py"), "Skip for compiled mypy")
1723
1723
  def test_count_get_proper_type(self) -> None:
@@ -31,6 +31,28 @@ class TestWriteJunitXml(TestCase):
31
31
  <testcase classname="mypy" file="mypy" line="1" name="mypy-py3.14-test-plat" time="1.230">
32
32
  </testcase>
33
33
  </testsuite>
34
+ """
35
+ result = _generate_junit_contents(
36
+ dt=1.23,
37
+ serious=serious,
38
+ messages_by_file=messages_by_file,
39
+ version="3.14",
40
+ platform="test-plat",
41
+ )
42
+ assert result == expected
43
+
44
+ def test_junit_fail_escape_xml_chars(self) -> None:
45
+ serious = False
46
+ messages_by_file: dict[str | None, list[str]] = {
47
+ "file1.py": ["Test failed", "another line < > &"]
48
+ }
49
+ expected = """<?xml version="1.0" encoding="utf-8"?>
50
+ <testsuite errors="0" failures="1" name="mypy" skips="0" tests="1" time="1.230">
51
+ <testcase classname="mypy" file="file1.py" line="1" name="mypy-py3.14-test-plat file1.py" time="1.230">
52
+ <failure message="mypy produced messages">Test failed
53
+ another line &lt; &gt; &amp;</failure>
54
+ </testcase>
55
+ </testsuite>
34
56
  """
35
57
  result = _generate_junit_contents(
36
58
  dt=1.23,