-
Notifications
You must be signed in to change notification settings - Fork 450
[BugFix] Fix ForwardRef usage in v2 frontend (#1619)
#1621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: tile-ai/tilelang
Length of output: 2072
🌐 Web query:
Python 3.10 typing.ForwardRef API changes is_argument module parameter💡 Result:
Short answer: In Python 3.10 the typing.ForwardRef constructor expanded beyond the original single extra flag (is_argument) — it accepts a module parameter (and an is_class kwarg) so you can provide the module context used when resolving the forward reference. See the ForwardRef implementation and discussion/issue references. [1][2]
Sources
References
[1] CPython typing.py — ForwardRef implementation.
[2] bpo issue 46371 — discussion of ForwardRef and module parameter.
🌐 Web query:
Python 3.10 typing.ForwardRef signature is_argument parameter still exists💡 Result:
Short answer: Yes — in Python 3.10 typing.ForwardRef accepted an is_argument parameter (ForwardRef(arg, is_argument=True)). This is how typing.get_type_hints in 3.10 converted string annotations to ForwardRef (and called _evaluate). See discussion and source excerpts showing ForwardRef(..., is_argument=...) and get_type_hints behavior. [1][2]
Note: the ForwardRef/_evaluate API has evolved in later CPython/PEP work (PEP 749 / annotationlib and changes around 3.13), so third‑party code that calls _evaluate directly may need adjustments for newer Python versions. [3][4]
Sources:
🌐 Web query:
Python 3.10 ForwardRef __init__ parameters module is_argument deprecated removed💡 Result:
Short answer — status and history:
If you need concrete compatibility guidance (exact signature in a specific CPython point release, or how to adapt code that passes is_argument/module to ForwardRef), tell me the Python patchlevel you care about (e.g., 3.10.0 vs 3.10.x) and I’ll cite the exact stdlib source for that release.
Sources:
[1] typeshed / typing.pyi (ForwardRef init notes).
[2] CPython typing.py source showing init with is_argument/module and _evaluate.
[3] PEP 749 / proposal discussing annotationlib and ForwardRef changes.
🌐 Web query:
ForwardRef module parameter Python 3.9 vs 3.10 behavior difference semantics💡 Result:
Short summary — what changed between Python 3.9 and 3.10 for typing.ForwardRef
Evaluation behavior: Python 3.10 changed how ForwardRefs are evaluated (more recursive evaluation and different evaluation order), and code that relied on the 3.9 evaluation/caching order can see different/resolved types or name-conflicts across modules. This was reported as a user-visible behavioral change (evaluation order/caching differences) in the Python issue tracker. [1][2]
The module parameter: ForwardRef has an internal module parameter used to resolve cross‑module forward references. Some fixes in the typing machinery (and related issues) made explicit use of or reliance on that module parameter in 3.10-era fixes; but TypedDict/NamedTuple and some nested cases still had gaps and required additional handling. Several tracker discussions show using ForwardRef(..., module=...) as a workaround in some cross-module cases. [1][3]
API/signature changes used by downstream libs: the internal ForwardRef evaluation implementation gained additional arguments used for recursion-guarding in later 3.x releases (code paths and private helper signatures changed). That caused downstream libraries (e.g., pydantic) to need version-conditional code to call ForwardRef._evaluate with an extra recursive_guard parameter. [4]
Practical effects
References
References (links):
[1] Python tracker — Issue 43646 (ForwardRef name conflict / evaluation changed in 3.10).
[2] Python tracker — Issue 46371 (discussion mentioning module parameter and cross-module ForwardRef resolution).
[3] Python tracker — Issue 46373 (TypedDict/NamedTuple cross-module ForwardRef evaluation limitations).
[4] pydantic issue: ForwardRef._evaluate recursive_guard signature differences and workarounds.
[5] Python docs — typing.ForwardRef.
🌐 Web query:
CPython typing.ForwardRef module parameter 3.9.7 3.10 implementation history💡 Result:
Summary — history of typing.ForwardRef's module parameter
Sources
References
[1] Python docs, typing — Support for type hints (ForwardRef added in 3.7.4).
[2] Python 3.10/3.11 typing docs (ForwardRef class description).
[3] CPython typing.py (older commit / implementation without module parameter).
[4] typeshed typing.pyi comment: "The module argument was added in Python 3.9.7."
[5] CPython typing.py (implementation with init(..., module=None, *, is_class=False)).
[6] bpo issue 46371 / 46373 (ForwardRef cross-module/type-alias resolution discussions).
[7] bpo issue 43646 / 42904 (ForwardRef evaluation behavior across versions).
If you want, I can fetch the exact CPython commit hashes and show the diff that introduced the module parameter (with dates and PR/commit links).
🏁 Script executed:
fd -t f '(setup.py|pyproject.toml|setup.cfg|README.md)' --maxdepth 2Repository: tile-ai/tilelang
Length of output: 116
🏁 Script executed:
Repository: tile-ai/tilelang
Length of output: 42
🏁 Script executed:
cat pyproject.toml | head -n 50Repository: tile-ai/tilelang
Length of output: 1827
The version-dependent ForwardRef construction works correctly, but the API history explanation needs correction.
The
moduleparameter was added in Python 3.9.7 (not 3.10), andis_argumentwas never deprecated—both parameters coexist in Python 3.10+. The version boundary of>= (3, 10)is therefore more conservative than strictly necessary given the project's Python >= 3.9 requirement. That said, the code implementation is sound and will function correctly across all supported versions. Usingfunc.__module__appropriately provides module context for type resolution.🤖 Prompt for AI Agents