Skip to content

[pull] main from facebook:main#1012

Merged
pull[bot] merged 14 commits into
CrazyForks:mainfrom
facebook:main
Jul 11, 2026
Merged

[pull] main from facebook:main#1012
pull[bot] merged 14 commits into
CrazyForks:mainfrom
facebook:main

Conversation

@pull

@pull pull Bot commented Jul 11, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

asukaminato0721 and others added 14 commits July 10, 2026 21:06
…m error #4094 (#4096)

Summary:
Fixes #4094

to_real_path will explicitly report no disk path for bundled stubs on WASM, and the website’s real-WASM suite will hover a standalone None and assert the returned hover. Native bundled-stub materialization remains unchanged.

Pull Request resolved: #4096

Test Plan: add test

Reviewed By: stroxler

Differential Revision: D111487777

Pulled By: grievejia

fbshipit-source-id: f6f163e30c26e6be0f1651db4e00a57dc68548f0
Summary:
Add the `unknown-lambda-type` error kind, which flags lambdas whose parameter or return type is inferred as an implicit `Any`.

fixes #4039

Reviewed By: stroxler

Differential Revision: D111052652

fbshipit-source-id: a84f6e7b401fdfffa785b5ae08f1dcf56f175b65
…extual type

Summary:
When a lambda parameter has a default value and no contextual hint constrains it, infer the parameter's type from the (promoted) default value — with `None` defaults inferred as `Any | None` — so both the lambda's signature and body see the type and `unknown-lambda-type` no longer false-fires on parameters with typed defaults.

the error delta has a few new errors but overall the delta is small. I'm neutral on landing this

Reviewed By: stroxler

Differential Revision: D111058951

fbshipit-source-id: f338a8ad625b646206daf6ea35067e4169d7c144
Summary:
Add the `implicit-any-variable` error kind (a sub-kind of `implicit-any`), which flags unannotated variables whose inferred type is an implicit `Any`.

fixes #4038

Reviewed By: kinto0

Differential Revision: D111080750

fbshipit-source-id: 0092872212ad06ed08fd5e965c3c8522eae248bd
Summary:
Extend implicit-any-attribute to also
fire when an unannotated attribute infers to bare implicit Any (e.g. from an
untyped call).

fixes #4037

Reviewed By: kinto0

Differential Revision: D111086501

fbshipit-source-id: 5962c178bb523319d55d50469d5ae2973e8ec30e
Summary:
This diff implements pyright's `reportUntypedClassDecorator` by adding an `untyped-class-decorator` error kind and reporting class decorator expressions whose inferred type is `Any`.

Fixes #4041

Reviewed By: kinto0

Differential Revision: D111284179

fbshipit-source-id: 8ce42f1ff1326c27e699af1fed5555e43d614552
Summary:
This diff implements pyright's reportUntypedFunctionDecorator by adding an untyped-function-decorator error kind and reporting function decorator expressions whose inferred type is Any.

fixes #4040

Reviewed By: kinto0

Differential Revision: D111285717

fbshipit-source-id: 4f02d6b7325155e30f0eecf8e6de48fd37d13781
Summary:
Fixes #4035.

This changes Pyrefly's TSP conversion for `None` from an off-spec `BuiltInType` named `none` to a `ClassType` instance declared as `types.NoneType`. The protocol's `BuiltInType.name` contract only allows sentinel names such as `unknown`, `any`, `ellipsis`, `never`, and `noreturn`, so encoding `None` as a class keeps `str | None` and other unions reconstructable by TSP consumers.

The change also updates the TSP interaction coverage for `x = None` so the actual wire response is checked as a class declaration rather than a builtin sentinel.

Pull Request resolved: #4043

Test Plan:
- `cargo +stable-x86_64-pc-windows-gnu test -p pyrefly tsp::type_conversion::tests:: -- --nocapture`
- `cargo +stable-x86_64-pc-windows-gnu test -p pyrefly test_get_computed_type_none_is_class -- --nocapture`
- `cargo +stable-x86_64-pc-windows-gnu test -p pyrefly tsp::type_conversion::tests::test_function_declaration_resolves_special_function_via_export -- --exact --nocapture`
- `RUSTUP_TOOLCHAIN=stable-x86_64-pc-windows-gnu python test.py --mode cargo --no-test --no-tensor-shapes --no-conformance --no-jsonschema`
- `git diff --check`

Reviewed By: stroxler

Differential Revision: D110961669

Pulled By: kinto0

fbshipit-source-id: 752e4f0a99e544969806e9dfc1bedc31ec5f58bd
Summary:
Follow-up to D110961669 addressing the review feedback on #4043.

D110961669 correctly stopped emitting the off-spec `none` `BuiltInType` and began encoding `None` as a `NoneType` `ClassType`, but it re-derived the `NoneType` location by name (`types` + `"NoneType"`), hardcoding `ModuleName::types()` and bundled `types.pyi`. That diverges from pyrefly's authoritative `Stdlib::none_type()`, which resolves `NoneType` from `types` only on Python 3.10+ and from `_typeshed` on older versions. On a project targeting < 3.10 the TSP declaration would therefore point at a different module than pyrefly's own `None` resolution and goto-definition.

This routes `None` through the real `Stdlib::none_type()` `ClassType` via the existing `convert_class_type(..., TypeFlags::INSTANCE)` path. `TypeConverter` now takes the resolved class, threaded down from the `server.rs` caller (which already computes `get_stdlib` on the warm transaction). Because the encoding reuses the actual class, it inherits the version-correct module and range automatically and is identical to an explicit `types.NoneType` annotation — no duplicated module/name/path logic. The `types_class`/`types_class_declaration`/`make_types_class_declaration` helpers (and their hardcoded `types.pyi`) are removed; resolver-free unit tests build a stand-in `NoneType` class so they still exercise the production path.

Tests are extended to cover the concrete #4035 symptom: a new interaction test asserts `str | None` round-trips with its `None` member as a reconstructable `NoneType` `ClassType`, and the existing test documents that the downstream Pylance hover (`str | Unknown` → `str | None`) should be confirmed against a real client.

Reviewed By: stroxler

Differential Revision: D111355122

fbshipit-source-id: 0486507ab1ab0b766d8cbca4cbf34309f4433d08
Summary:
`convert_type_with_resolvers` took the `NoneType` class as a bare positional argument, added when `None` was routed through the real `Stdlib::none_type()`. Encoding more sentinel-like types (`TypeGuard`/`TypeIs` as `bool`, `Size`/`Dim` as `int`) the same way would keep growing the positional-argument list and force every caller and test to thread each class separately.

This is a pure no-op refactor that replaces the single `none_type` parameter with a `StdlibClasses` bundle carrying the stdlib classes the converter uses to encode types that would otherwise be off-spec `BuiltInType` sentinels. Today it holds only `none_type`; follow-up diffs add fields for the other classes without touching any callsite signatures.

The resolver-free unit tests grow a small `TestStdlib` owner (with a `classes()` accessor) and a generalized `test_class(module, name)` helper, so a test can mint whatever stand-in classes it needs and borrow them as an `StdlibClasses`.

Reviewed By: stroxler

Differential Revision: D111366189

fbshipit-source-id: 2d1a3b40d9ae604a21d4c57bbd2ce7730614ca47
Summary:
`TypeGuard[X]`/`TypeIs[X]` erase to their runtime type `bool`, but the TSP conversion emitted them as `bool` `BuiltInType`. The protocol restricts `BuiltInType.name` to a fixed sentinel set (`unknown`/`any`/`unbound`/`ellipsis`/`never`/`noreturn`) that does not include `bool`, so consumers render off-spec names as `Unknown` — the same class of bug that motivated routing `None` through the real `NoneType` class.

This encodes `TypeGuard`/`TypeIs` as the stdlib's `bool` `ClassType` via the existing `convert_class_type(..., INSTANCE)` path, threaded through the `StdlibClasses` bundle. The declaration inherits `bool`'s real module and range, so it is navigable and identical to an explicit `bool` annotation.

Reviewed By: yangdanny97

Differential Revision: D111366448

fbshipit-source-id: 764bff2818d026c288874f22820ba6774b9cbe25
Summary:
Pull Request resolved: #4095

`Size`/`Dim` (integer tensor dimensions) were emitted as `int` `BuiltInType`. The protocol restricts `BuiltInType.name` to a fixed sentinel set that does not include `int`, so consumers render the off-spec name as `Unknown` — the same class of bug fixed for `None` and `TypeGuard`/`TypeIs`.

This encodes `Size`/`Dim` as the stdlib's `int` `ClassType` via the existing `convert_class_type(..., INSTANCE)` path, threaded through the `StdlibClasses` bundle. The declaration inherits `int`'s real module and range, so it is navigable and identical to an explicit `int` annotation.

Reviewed By: yangdanny97

Differential Revision: D111366731

fbshipit-source-id: f9d2a553da4aebd6fcaca3f6eebdce5bd9c35a00
Summary:
`Sentinel` types were emitted as `sentinel` `BuiltInType`. The protocol restricts `BuiltInType.name` to a fixed sentinel set that does not include `sentinel`, so consumers render the off-spec name as `Unknown` — while the protocol already has a dedicated `SentinelLiteral` (class name plus defining location) for exactly this case.

This emits a `ClassType` carrying a `SentinelLiteral`, built entirely from the sentinel's own `QName`. Unlike the `None`/`bool`/`int` cases, no stdlib class is threaded in: the sentinel's declaration and literal location are its own definition, so goto-definition points at the real sentinel class.

Reviewed By: yangdanny97

Differential Revision: D111366758

fbshipit-source-id: 17969fd5633cc48764cc4f337bdacdca1bac4190
Summary: [pyrefly][dev] cut 1.2.0-dev.2

Reviewed By: yangdanny97

Differential Revision: D111511472

fbshipit-source-id: 7e6703e1e15e2a41ce9902176293566640ceb822
@pull pull Bot locked and limited conversation to collaborators Jul 11, 2026
@pull pull Bot added the ⤵️ pull label Jul 11, 2026
@pull pull Bot merged commit 6d3de14 into CrazyForks:main Jul 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants