GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — Enable TypeForm support by default by davidfstr · Pull Request #11412 · microsoft/pyright Conversation
Contributor
...rather than requiring the --enableExperimentalFeatures bit to be set CONTEXT:
OPEN QUESTIONS:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
...rather than requiring the --enableExperimentalFeatures bit to be set ...by the current interence context or because EvalFlags.TypeFormArg is set.
Without this optimization, the call5.py test fails where it defines a
NamedTuple "X", [("a", int), ...]. Attempting to interpret the string "a"
as a forward reference looks up the name `a` (bound by a later for-loop),
and the resulting flow analysis recursively re-enters the Z(...) constructor,
causing a "Class definition for Z depends on itself" error.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Misspelling in commit message: "current interence context" -> "current inference context"
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. Squish change to -> Do not try to interpret a string as a TypeForm unless one is expected Squish to -> Do not try to interpret a string as a TypeForm unless one is expected Squish to -> Enable TypeForm support by default
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
Holy moly. diophantine.py is complex. I think I'm going to disregard the remaining error deltas in sympy. sympy was already producing very many errors under pyright before this branch and now its producing very many but different errors after this branch. Not worth the investigation time: sympy was already broken at the start. I've just pushed up commits integrating the outstanding feedback. NextSo the next item (and possibly last) item I want to investigate is any performance regressions that this branch might introduce. I'll look at the psf/black codebase as issue #11008 did. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GitHub cannot anchor PR review comments to unchanged lines in the diff. Falling back to a general PR comment for packages/pyright-internal/src/analyzer/typeEvaluator.ts:L5574. Copilot generated: Suggested fix: function expectedTypeWantsTypeForm(expectedType: Type): boolean { return someSubtypes(expectedType, (subtype) => isClassInstance(subtype) && ClassType.isBuiltIn(subtype, 'TypeForm') ); } 🔍 Structurally confirmed: [verified] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
GitHub cannot anchor PR review comments to unchanged lines in the diff. Falling back to a general PR comment for packages/pyright-internal/src/analyzer/typeEvaluator.ts:L7659. Copilot generated:
[verified] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GitHub cannot anchor PR review comments to unchanged lines in the diff. Falling back to a general PR comment for packages/pyright-internal/src/analyzer/typeEvaluator.ts:L990. Copilot generated: All 7 TypeForm test files (typeForm1–7) still explicitly set [verified] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Update: The following item is still my next item for this PR:
Before I start the item, I will investigate/fix a performance regression on a similar PR in mypy. I expect I may be able to take learnings from that future fix and apply them to this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Update: I'm continuing to fix performance regressions in mypy. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This reverts commit 7233033.
Adds a dev-facing tool, adapted from mypy's misc/perf_compare.py, that builds the production pyright CLI bundle at each of two or more commits and times repeated runs over a fixed corpus, reporting robust winsorized paired deltas vs a baseline. Supports wall or CPU-time metrics and single-file or project corpora. Cached bundles live beside the script under build/perfCompare/binaries/ (gitignored). Also adds a brief pointer in CONTRIBUTING.md. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
I profiled this branch's changes against two targets ("corpuses"):
and found no significant performance regression in either. Performance
Setup: Clone the corpus next to the pyright repo: psf/black's entire repo - branch base vs branch tip
Not significant (CI includes 0). psf/black's
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Review feedback suggested short-circuiting cloneWithTypeForm with
`if (type.props?.typeForm === typeForm) return type;` (mirroring
cloneForCondition) to avoid allocations on the now-unconditional call
sites. After measuring, this is not worth doing: the no-op case occurs in
only ~0.2% of calls, so the guard would add a branch to the hot path while
saving almost no allocations. No code change is made.
The reference-equality check rarely holds because nearly every call site
passes a freshly-allocated value (e.g. convertToInstance(type)), which is a
new object every time. A value-equality check (isTypeSame) would catch more
cases but costs far more than the allocation it would save, so it is a net
loss on the hot path.
Supporting data (instrumented cloneWithTypeForm over the full
typeEvaluator jest suite, 1,162 tests):
cloneWithTypeForm calls : ~12,000
`=== typeForm` would fire: 23 (~0.2%)
of which both undefined: 22 (~0.18%)
non-undefined ref match: 1
So the general `=== typeForm` guard buys essentially nothing beyond the
both-undefined case, which is itself only ~0.18% of calls.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Addresses review feedback: the TypeForm tests set enableExperimentalFeatures = true, so none validated this PR's core claim that TypeForm is enabled by default. Remove the flag from the existing TypeForm1-8 tests so they all exercise the default configuration and directly prove the isTypeFormSupported gate removal is effective. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…s expected Fix prettier whitespace issue
|
Rich Chiodo (@rchiodo) I've added commits addressing all your outstanding feedback. The PR branch is now pretty messy, with a lot of commits that should ultimately be squashed. Would you mind if I reordered/squashed the commits to get a clean history? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
If you want to squash that's fine. When we merge the PR, we'll also squash everything so it doesn't really matter which. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Diff from mypy_primer, showing the effect of this PR on open source code: sympy (https://github.com/sympy/sympy) + .../projects/sympy/sympy/polys/euclidtools.py:1974:24 - error: Argument of type "dmp[Er@dmp_cancel] | Unknown | dup[Unknown]" cannot be assigned to parameter "f" of type "dmp[Er@dmp_mul_ground]" in function "dmp_mul_ground" + Type "dmp[Er@dmp_cancel] | Unknown | dup[Unknown]" is not assignable to type "dmp[Er@dmp_mul_ground]" + "builtins.list" is not assignable to "builtins.list" + Type parameter "_T@list" is invariant, but "dmp" is not the same as "dmp" + Consider switching from "list" to "Sequence" which is covariant (reportArgumentType) + .../projects/sympy/sympy/polys/euclidtools.py:1974:34 - error: Argument of type "Domain[Er@dmp_cancel] | Ring[Unknown]" cannot be assigned to parameter "K" of type "Domain[Er@dmp_mul_ground]" in function "dmp_mul_ground" + Type "Domain[Er@dmp_cancel] | Ring[Unknown]" is not assignable to type "Domain[Er@dmp_mul_ground]" + "Domain[Er@dmp_cancel]" is not assignable to "Domain[Er@dmp_mul_ground]" + Type parameter "Er@Domain" is invariant, but "Er@dmp_cancel" is not the same as "Er@dmp_mul_ground" (reportArgumentType) - .../projects/sympy/sympy/polys/euclidtools.py:1976:12 - error: Type "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel]]" is not assignable to return type "tuple[dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]] | tuple[Er@dmp_cancel, Er@dmp_cancel, dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" + .../projects/sympy/sympy/polys/euclidtools.py:1976:12 - error: Type "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel | Unknown]]" is not assignable to return type "tuple[dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]] | tuple[Er@dmp_cancel, Er@dmp_cancel, dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" - Type "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel]]" is not assignable to type "tuple[dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]] | tuple[Er@dmp_cancel, Er@dmp_cancel, dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" + Type "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel | Unknown]]" is not assignable to type "tuple[dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]] | tuple[Er@dmp_cancel, Er@dmp_cancel, dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" - "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel]]" is not assignable to "tuple[Er@dmp_cancel, Er@dmp_cancel, dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" + "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel | Unknown]]" is not assignable to "tuple[Er@dmp_cancel, Er@dmp_cancel, dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" - "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel]]" is not assignable to "tuple[dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" + "tuple[dmp[Er@dmp_cancel | Unknown | RingElement*], dmp[Er@dmp_cancel | Unknown]]" is not assignable to "tuple[dmp[Er@dmp_cancel], dmp[Er@dmp_cancel]]" - .../projects/sympy/sympy/solvers/ode/hypergeometric.py:247:67 - error: Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue) + .../projects/sympy/sympy/solvers/ode/lie_group.py:619:61 - error: Operator "-" not supported for type "Unknown | Basic" (reportOperatorIssue) - .../projects/sympy/sympy/solvers/ode/nonhomogeneous.py:468:28 - error: Argument of type "Expr | Unknown | None" cannot be assigned to parameter "expr" of type "Expr" in function "make_args" + .../projects/sympy/sympy/solvers/ode/nonhomogeneous.py:468:28 - error: Argument of type "Unknown | None" cannot be assigned to parameter "expr" of type "Expr" in function "make_args" - Type "Expr | Unknown | None" is not assignable to type "Expr" + Type "Unknown | None" is not assignable to type "Expr" - .../projects/sympy/sympy/solvers/ode/ode.py:1579:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:1580:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:1590:9 - error: No overloads for "update" match the provided arguments (reportCallIssue) - .../projects/sympy/sympy/solvers/ode/ode.py:1590:12 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess) - .../projects/sympy/sympy/solvers/ode/ode.py:1590:19 - error: Argument of type "Unknown | dict[Unknown, Unknown] | None" cannot be assigned to parameter "m" of type "Iterable[tuple[str, Unknown]]" in function "update" - Type "Unknown | dict[Unknown, Unknown] | None" is not assignable to type "Iterable[tuple[str, Unknown]]" - "None" is incompatible with protocol "Iterable[tuple[str, Unknown]]" - "__iter__" is not present (reportArgumentType) - .../projects/sympy/sympy/solvers/ode/ode.py:1597:43 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:1597:64 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:1603:9 - error: No overloads for "update" match the provided arguments (reportCallIssue) - .../projects/sympy/sympy/solvers/ode/ode.py:1603:12 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess) - .../projects/sympy/sympy/solvers/ode/ode.py:1603:19 - error: Argument of type "Unknown | dict[Unknown, Unknown] | None" cannot be assigned to parameter "m" of type "Iterable[tuple[str, Unknown]]" in function "update" - Type "Unknown | dict[Unknown, Unknown] | None" is not assignable to type "Iterable[tuple[str, Unknown]]" - "None" is incompatible with protocol "Iterable[tuple[str, Unknown]]" - "__iter__" is not present (reportArgumentType) - .../projects/sympy/sympy/solvers/ode/ode.py:1610:43 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:1610:74 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:1616:9 - error: No overloads for "update" match the provided arguments (reportCallIssue) - .../projects/sympy/sympy/solvers/ode/ode.py:1616:12 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess) - .../projects/sympy/sympy/solvers/ode/ode.py:1616:19 - error: Argument of type "Unknown | dict[Unknown, Unknown] | None" cannot be assigned to parameter "m" of type "Iterable[tuple[str, Unknown]]" in function "update" - Type "Unknown | dict[Unknown, Unknown] | None" is not assignable to type "Iterable[tuple[str, Unknown]]" - "None" is incompatible with protocol "Iterable[tuple[str, Unknown]]" - "__iter__" is not present (reportArgumentType) - .../projects/sympy/sympy/solvers/ode/ode.py:1623:49 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:1623:70 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) + .../projects/sympy/sympy/solvers/ode/ode.py:1753:36 - error: Cannot access attribute "lhs" for class "Expr" + Attribute "lhs" is unknown (reportAttributeAccessIssue) + .../projects/sympy/sympy/solvers/ode/ode.py:1753:55 - error: Cannot access attribute "rhs" for class "Expr" + Attribute "rhs" is unknown (reportAttributeAccessIssue) + .../projects/sympy/sympy/solvers/ode/ode.py:1754:36 - error: Cannot access attribute "lhs" for class "Expr" + Attribute "lhs" is unknown (reportAttributeAccessIssue) + .../projects/sympy/sympy/solvers/ode/ode.py:1755:17 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue) + .../projects/sympy/sympy/solvers/ode/ode.py:1755:17 - error: Argument of type "Equality | BooleanFalse | BooleanTrue | Unknown | Expr" cannot be assigned to parameter "value" of type "Equality | BooleanFalse | BooleanTrue" in function "__setitem__" + Type "Equality | BooleanFalse | BooleanTrue | Unknown | Expr" is not assignable to type "Equality | BooleanFalse | BooleanTrue" + Type "Expr" is not assignable to type "Equality | BooleanFalse | BooleanTrue" + "Expr" is not assignable to "Equality" + "Expr" is not assignable to "BooleanFalse" + "Expr" is not assignable to "BooleanTrue" (reportArgumentType) - .../projects/sympy/sympy/solvers/ode/ode.py:3442:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess) - .../projects/sympy/sympy/solvers/ode/ode.py:3442:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3443:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess) - .../projects/sympy/sympy/solvers/ode/ode.py:3443:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3444:14 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3445:14 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3446:14 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3458:50 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3459:50 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3460:50 - error: Object of type "None" is not subscriptable (reportOptionalSubscript) - .../projects/sympy/sympy/solvers/ode/ode.py:3500:5 - error: No overloads for "update" match the provided arguments (reportCallIssue) - .../projects/sympy/sympy/solvers/ode/ode.py:3500:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess) ... (truncated 102 lines) ... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
David Foster (@davidfstr), thanks for the PR |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
TypeForm support is enabled by default following #11412. Co-authored-by: Copilot App <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.