pyrefly-shape-extensions 1.1.1__tar.gz → 1.2.0.dev1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyrefly-shape-extensions
3
- Version: 1.1.1
3
+ Version: 1.2.0.dev1
4
4
  Summary: Shape typing primitives and DSL for Pyrefly tensor shape tracking
5
5
  Project-URL: homepage, https://pyrefly.org
6
6
  Project-URL: documentation, https://pyrefly.org/en/docs/
@@ -8,7 +8,7 @@ description = "Shape typing primitives and DSL for Pyrefly tensor shape tracking
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.12"
10
10
  license = { file = "LICENSE" }
11
- version = "1.1.1"
11
+ version = "1.2.0.dev1"
12
12
  keywords = ["typechecker", "typechecking", "shapes", "tensor", "pyrefly"]
13
13
  classifiers = [
14
14
  "Development Status :: 4 - Beta",
@@ -16,6 +16,14 @@ import typing
16
16
  from dataclasses import dataclass
17
17
 
18
18
 
19
+ def _return_class(cls, params):
20
+ return cls
21
+
22
+
23
+ def _return_int(cls, params):
24
+ return int
25
+
26
+
19
27
  def _patch_torch_if_available() -> None:
20
28
  try:
21
29
  import torch # @manual
@@ -54,7 +62,7 @@ def _patch_torch_if_available() -> None:
54
62
  ]
55
63
  for cls in subscriptable_classes:
56
64
  if not hasattr(cls, "__class_getitem__"):
57
- cls.__class_getitem__ = classmethod(lambda cls, params: cls)
65
+ cls.__class_getitem__ = classmethod(_return_class)
58
66
 
59
67
 
60
68
  _patch_torch_if_available()
@@ -70,6 +78,16 @@ class Dim[T]:
70
78
  pass
71
79
 
72
80
 
81
+ def enable_torchscript_runtime_compat() -> None:
82
+ """Erase shape-only runtime annotations to types TorchScript understands.
83
+
84
+ This is a one-way, process-global compatibility mode for legacy TorchScript
85
+ paths. It intentionally has no disable API for production callers.
86
+ """
87
+
88
+ Dim.__class_getitem__ = classmethod(_return_int)
89
+
90
+
73
91
  @dataclass(frozen=True)
74
92
  class SymbolicArithExpr:
75
93
  """Runtime representation of symbolic dimension arithmetic."""