Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Splitting unknown-name error code#2584

Open
Karman-singh15 wants to merge 2 commits intofacebook:mainfrom
Karman-singh15:fix-unknown-name-error
Open

Splitting unknown-name error code#2584
Karman-singh15 wants to merge 2 commits intofacebook:mainfrom
Karman-singh15:fix-unknown-name-error

Conversation

@Karman-singh15
Copy link
Contributor

Summary

This PR adds two new error kinds, UnimportedAssertType and UnimportedRevealType, to make error reporting more specific when assert_type or reveal_type are used without being imported. Instead of falling back to the generic unknown-name error, the binding logic now emits these dedicated error types. Both were added to the ErrorKind enum with a default severity of Error. I also updated the documentation to describe the new error kinds and adjusted the relevant test expectations to match the new diagnostics, while keeping the existing Rust unit tests unchanged to ensure everything still aligns with the intended error behavior.

Fixes #2550

Test Plan

I verified that cargo test test_assert_type_variations and cargo test test_reveal_type_variations both run and pass after the changes. I also made sure the new configuration values are properly sorted and parsed as expected by the existing framework. With this update, users can now suppress these specific diagnostics using # pyrefly: ignore[unimported-reveal-type] (or the corresponding assert type rule) without having to ignore all unknown-name errors, which keeps suppression more precise and intentional.

@meta-cla meta-cla bot added the cla signed label Feb 27, 2026
@github-actions

This comment has been minimized.

@yangdanny97 yangdanny97 self-assigned this Feb 28, 2026
Copy link
Contributor

@yangdanny97 yangdanny97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the comments of the original issue @rchen152 mentioned we can just use a single new error kind for this, rather than two.

Let's rename it UnimportedDirective since the typing spec calls assert_type/reveal_type/cast directives: https://typing.python.org/en/latest/spec/directives.html#type-checker-directives

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

Diff from mypy_primer, showing the effect of this PR on open source code:

cloud-init (https://github.com/canonical/cloud-init)
- ERROR cloudinit/config/cc_ca_certs.py:118:44-120:6: No matching overload found for function `posixpath.join` called with arguments: (list[str] | str | Unknown | None, list[str] | str | Unknown | None) [no-matching-overload]
+ ERROR cloudinit/config/cc_ca_certs.py:118:44-120:6: No matching overload found for function `posixpath.join` called with arguments: (list[str] | str | None, list[str] | str | None) [no-matching-overload]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- ERROR tests/annotations/behaviors.py:73:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/behaviors.py:73:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/behaviors.py:84:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/behaviors.py:84:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:79:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:79:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:84:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:84:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:89:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:89:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:90:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:90:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:97:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:97:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:104:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:104:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:110:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:110:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:111:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:111:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:112:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:112:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:117:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:117:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:119:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:119:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:121:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:121:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:125:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:125:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:130:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:130:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:132:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:132:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:134:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:134:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:136:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:136:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:138:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:138:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:140:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:140:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:150:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:150:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:151:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:151:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:152:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:152:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:153:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:153:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:155:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:155:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:156:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:156:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:157:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:157:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:158:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:158:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:159:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:159:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:160:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:160:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:161:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:161:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:162:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:162:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:163:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:163:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:166:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:166:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:167:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:167:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:173:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:173:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:174:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:174:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:175:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:175:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:186:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:186:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:187:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:187:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:192:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:192:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:193:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:193:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:194:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:194:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:195:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:195:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:198:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:198:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:199:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:199:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:202:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:202:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:205:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:205:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:207:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:207:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:208:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:208:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:209:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:209:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:210:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:210:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:218:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:218:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:228:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:228:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:229:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:229:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:230:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:230:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:231:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:231:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:232:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:232:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:236:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:236:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:241:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:241:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:245:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:245:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:249:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:249:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:253:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:253:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:257:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:257:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:261:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:261:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:274:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:274:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:275:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:275:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:299:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:299:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:325:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:325:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:336:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:336:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:348:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:348:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:433:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:433:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:436:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:436:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:456:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:456:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:477:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:477:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:478:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:478:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:483:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:483:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:486:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:486:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:505:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:505:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:506:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:506:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:510:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:510:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:511:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:511:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:513:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:513:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:514:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:514:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:516:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:516:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:517:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:517:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:520:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:520:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:521:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:521:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:524:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:524:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:554:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:554:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:558:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:558:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]
- ERROR tests/annotations/declarations.py:562:5-16: `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
+ ERROR tests/annotations/declarations.py:562:5-16: `reveal_type` must be imported from `typing` for runtime usage [unimported-directive]

... (truncated 180 lines) ...

@github-actions
Copy link

Primer Diff Classification

➖ 2 neutral | 2 project(s) total

Project Verdict Changes Error Kinds Root Cause
cloud-init ➖ Neutral +1, -1 no-matching-overload
hydra-zen ➖ Neutral +183, -183 unimported-directive, unknown-name pyrefly/lib/binding/expr.rs
Detailed analysis

➖ Neutral (2)

cloud-init (+1, -1)

Same errors at same locations with same error kinds — message wording changed, no behavioral impact.

hydra-zen (+183, -183)

This is a neutral change that improves error reporting specificity without changing behavior. The PR splits the generic unknown-name error into more specific categories when type checker directives like reveal_type and assert_type are used without proper imports. The same underlying issue is still detected (using reveal_type without importing it from typing), but now it's reported with a more descriptive error code unimported-directive instead of the generic unknown-name. This allows users to suppress these specific diagnostics more precisely using # pyrefly: ignore[unimported-directive] rather than having to ignore all unknown-name errors. The error detection capability remains identical - only the categorization has improved.
Attribution: The change in pyrefly/lib/binding/expr.rs modified the error reporting for special names like reveal_type and assert_type from ErrorKind::UnknownName to ErrorKind::UnimportedDirective, and added the new error kind in crates/pyrefly_config/src/error_kind.rs.


Was this helpful? React with 👍 or 👎

Classification by primer-classifier (1 heuristic, 1 LLM)

@Karman-singh15
Copy link
Contributor Author

can you review the changes

@yangdanny97 yangdanny97 self-requested a review March 1, 2026 00:24
@meta-codesync
Copy link

meta-codesync bot commented Mar 2, 2026

@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D94923965.

Copy link
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way to suppress unknown-name diagnostics for reveal_type usages

3 participants