Skip to content

fix Conformance: Missing type alias validation #2451#3174

Open
asukaminato0721 wants to merge 14 commits intofacebook:mainfrom
asukaminato0721:2451
Open

fix Conformance: Missing type alias validation #2451#3174
asukaminato0721 wants to merge 14 commits intofacebook:mainfrom
asukaminato0721:2451

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

@asukaminato0721 asukaminato0721 commented Apr 18, 2026

Summary

Fixes #2451

factored the syntax check into a reusable helper.

detect NameAssign bindings that were never real implicit aliases and surface the syntax error at the annotation use site.

preserves normal runtime-value typing while fixing the implicit-alias false negatives.

Test Plan

update test

@meta-cla meta-cla Bot added the cla signed label Apr 18, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review April 18, 2026 08:34
Copilot AI review requested due to automatic review settings April 18, 2026 08:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes missing validation for “implicit type aliases” whose RHS is not a valid annotation/type-expression syntax, ensuring these now error at the annotation use site (conformance #2451). The PR also refactors annotation-syntax validation into a reusable helper and updates conformance baselines.

Changes:

  • Refactor annotation syntax validation into annotation_syntax_problem and reuse it for diagnostics.
  • Detect invalid implicit type-alias bindings (via NameAssign) and surface InvalidAnnotation at the annotation usage site.
  • Update tests and third-party conformance expectation/result artifacts to reflect the new diagnostics.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyrefly/lib/alt/solve.rs Adds reusable annotation-syntax helper and new implicit type-alias syntax validation that reports invalid-annotation at use sites.
pyrefly/lib/test/type_alias.rs Updates the conformance test case to expect the new, more specific annotation-syntax errors.
conformance/third_party/results.json Updates aggregated third-party conformance pass/fail counts.
conformance/third_party/conformance.result Updates per-test expectation summary to reflect aliases_implicit.py now passing.
conformance/third_party/conformance.exp Updates expected diagnostic outputs (messages/kinds) for the affected conformance cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyrefly/lib/alt/solve.rs Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/l and removed size/l labels Apr 18, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/l and removed size/l labels Apr 18, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@migeed-z migeed-z self-assigned this Apr 20, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 20, 2026

@migeed-z has imported this pull request. If you are a Meta employee, you can view this in D101670073.

Comment thread pyrefly/lib/alt/solve.rs Outdated
Comment thread pyrefly/lib/test/type_alias.rs
Comment thread pyrefly/lib/test/type_alias.rs
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@migeed-z
Copy link
Copy Markdown
Contributor

Hmmm. I am not sure this approach is the right one. The reason is that something like this:

DynClass = type("DynClass", (), {})
def f(x: DynClass) -> None:  # E: Function call cannot be used in annotations
    pass

will fail and introduce false positives. The reason is that we are interpreting type(..) as a function call and rejecting it, but we should interpret the type of the value instead. So I think the approach needs to be modified to do that instead.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/pyrefly_types/src/type_info.rs Outdated
Comment thread pyrefly/lib/alt/solve.rs
Comment on lines +650 to +653
let anon_key = Key::Anon(call.range);
self.bindings()
.key_to_idx_hashed_opt(Hashed::new(&anon_key))
.is_some_and(|idx| matches!(self.bindings().get(idx), Binding::ClassDef(..)))
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

call_has_synthesized_runtime_type duplicates the synthesized_functional_class_type binding lookup logic that already exists on AnswersSolver (pyrefly/lib/alt/expr.rs). Reusing that helper (or factoring the shared logic) would reduce duplication and help keep the anon-key/classdef detection consistent across the codebase.

Suggested change
let anon_key = Key::Anon(call.range);
self.bindings()
.key_to_idx_hashed_opt(Hashed::new(&anon_key))
.is_some_and(|idx| matches!(self.bindings().get(idx), Binding::ClassDef(..)))
self.synthesized_functional_class_type(call.range).is_some()

Copilot uses AI. Check for mistakes.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/l and removed size/l labels Apr 23, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review April 23, 2026 23:44
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread crates/pyrefly_types/src/type_info.rs Outdated
use crate::types::Type;

assert_bytes!(TypeInfo, 40);
assert_bytes!(TypeInfo, 64);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to store name_assign_type_form or would it be better to lookup this info on the fly?

@github-actions
Copy link
Copy Markdown

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

bokeh (https://github.com/bokeh/bokeh)
- ERROR src/bokeh/document/config.pyi:21:19-30: Expected a type form, got instance of `Enumeration` [not-a-type]
+ ERROR src/bokeh/document/config.pyi:21:19-30: Function call cannot be used in annotations [invalid-annotation]

pytest-autoprofile (https://gitlab.com/TTsangSC/pytest-autoprofile)
- ERROR src/pytest_autoprofile/_typing.py:81:10-14: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/pytest_autoprofile/_typing.py:81:10-14: Function call cannot be used in annotations [invalid-annotation]

async-utils (https://github.com/mikeshardmind/async-utils)
- ERROR src/async_utils/_as_completed.py:46:34-35: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/_as_completed.py:46:34-35: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/_as_completed.py:58:40-41: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/_as_completed.py:58:40-41: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/_graphs.py:83:30-45: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/_graphs.py:84:20-35: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/_graphs.py:83:30-45: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/_graphs.py:84:20-35: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/_graphs.py:127:38-53: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/_graphs.py:127:70-85: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/_graphs.py:127:38-53: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/_graphs.py:127:70-85: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/_graphs.py:138:36-51: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/_graphs.py:138:66-81: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/_graphs.py:138:36-51: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/_graphs.py:138:66-81: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/lru.py:89:27-28: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/lru.py:89:27-28: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/lru.py:123:32-33: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:123:41-42: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:127:32-33: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:127:42-43: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:135:31-32: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:135:41-42: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:135:50-51: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:157:27-28: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/lru.py:123:32-33: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:123:41-42: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:127:32-33: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:127:42-43: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:135:31-32: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:135:41-42: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:135:50-51: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:157:27-28: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/lru.py:275:32-33: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:275:41-42: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:283:32-33: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:283:42-43: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/lru.py:295:27-28: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/lru.py:275:32-33: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:275:41-42: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:283:32-33: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:283:42-43: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/lru.py:295:27-28: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/lru.py:319:27-28: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/lru.py:319:27-28: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/scheduler.py:44:51-52: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/scheduler.py:46:23-24: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/scheduler.py:44:51-52: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/scheduler.py:46:23-24: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/scheduler.py:98:34-35: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR src/async_utils/scheduler.py:119:60-61: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/scheduler.py:98:34-35: Function call cannot be used in annotations [invalid-annotation]
+ ERROR src/async_utils/scheduler.py:119:60-61: Function call cannot be used in annotations [invalid-annotation]
- ERROR src/async_utils/waterfall.py:108:25-26: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR src/async_utils/waterfall.py:108:25-26: Function call cannot be used in annotations [invalid-annotation]

mypy (https://github.com/python/mypy)
- ERROR mypy/typeshed/stdlib/typing.pyi:151:14-16: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:151:21-23: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:383:29-31: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:383:39-41: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:151:14-16: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:151:21-23: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:383:29-31: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:383:39-41: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:410:20-22: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:410:27-29: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:411:24-26: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:411:31-33: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:410:20-22: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:410:27-29: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:411:24-26: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:411:31-33: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:421:34-37: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:421:42-45: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:421:34-37: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:421:42-45: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:466:28-31: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:466:36-39: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:466:28-31: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:466:36-39: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:501:26-31: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:501:26-31: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:511:45-50: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:511:45-50: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:534:27-32: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:534:27-32: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:548:27-37: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:550:27-40: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:550:48-58: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:555:10-20: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:558:98-108: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:548:27-37: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:550:27-40: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:550:48-58: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:555:10-20: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:558:98-108: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:592:27-43: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:592:51-61: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:597:10-20: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:600:98-108: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:592:27-43: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:592:51-61: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:597:10-20: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:600:98-108: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:630:28-41: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:630:28-41: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:658:45-50: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:658:45-50: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:671:41-43: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:674:45-47: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:671:41-43: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:674:45-47: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:680:46-48: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:680:46-48: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:691:29-31: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:691:29-31: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:695:42-44: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:696:29-31: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:695:42-44: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:696:29-31: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:719:26-28: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:721:30-32: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:724:22-24: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:725:29-31: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:719:26-28: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:721:30-32: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:724:22-24: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:725:29-31: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:780:32-35: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:780:43-49: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:783:24-27: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:780:32-35: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:780:43-49: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:783:24-27: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:787:24-27: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:787:38-40: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:787:24-27: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:787:38-40: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:796:32-35: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:796:44-47: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:798:32-35: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:801:24-27: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:801:35-38: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:803:24-27: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:803:38-41: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:803:49-52: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:805:24-27: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:805:38-40: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:796:32-35: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:796:44-47: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:798:32-35: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:801:24-27: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:801:35-38: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:803:24-27: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:803:38-41: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:803:49-52: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:805:24-27: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:805:38-40: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:814:63-66: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:814:63-66: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:816:31-34: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:816:45-48: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:816:56-59: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:816:31-34: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:816:45-48: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:816:56-59: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:840:99-102: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:840:99-102: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:844:92-95: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:844:92-95: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:846:62-65: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:846:62-65: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:877:39-45: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:881:47-53: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:877:39-45: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:881:47-53: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:899:24-30: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:899:24-30: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:907:27-33: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:907:27-33: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypy/typeshed/stdlib/typing.pyi:985:38-40: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:992:26-28: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:992:36-38: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:994:26-28: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:994:46-48: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:1051:39-41: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:1157:26-28: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypy/typeshed/stdlib/typing.pyi:1157:36-38: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypy/typeshed/stdlib/typing.pyi:985:38-40: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:992:26-28: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:992:36-38: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:994:26-28: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:994:46-48: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:1051:39-41: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:1157:26-28: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypy/typeshed/stdlib/typing.pyi:1157:36-38: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:14:34-37: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:14:42-45: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:16:42-45: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:16:54-57: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:17:29-32: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:17:37-40: Expected a type form, got instance of `object` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:14:34-37: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:14:42-45: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:16:42-45: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:16:54-57: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:17:29-32: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:17:37-40: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:69:27-31: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:69:27-31: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:73:27-28: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:73:33-34: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:76:26-29: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:76:36-39: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:76:50-53: Expected a type form, got instance of `object` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:73:27-28: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:73:33-34: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:76:26-29: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:76:36-39: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:76:50-53: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:89:28-29: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:89:28-29: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:92:27-30: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:92:37-40: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:92:51-54: Expected a type form, got instance of `object` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:92:27-30: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:92:37-40: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:92:51-54: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:110:27-28: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:110:33-34: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:113:26-29: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:113:36-39: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:113:50-53: Expected a type form, got instance of `object` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:110:27-28: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:110:33-34: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:113:26-29: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:113:36-39: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:113:50-53: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:131:30-33: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:131:38-42: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:131:30-33: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:131:38-42: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:135:32-33: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:135:38-42: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:135:32-33: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:135:38-42: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:137:22-23: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:137:22-23: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:139:22-23: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:139:22-23: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:146:30-31: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:146:36-37: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:146:30-31: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:146:36-37: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:154:28-29: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:154:34-35: Expected a type form, got instance of `TypeVar` [not-a-type]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:154:28-29: Function call cannot be used in annotations [invalid-annotation]
+ ERROR mypyc/test-data/fixtures/typing-full.pyi:154:34-35: Function call cannot be used in annotations [invalid-annotation]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:158:28-29: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:160:34-37: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:160:50-53: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:160:66-69: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:160:74-77: Expected a type form, got instance of `object` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:169:20-21: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:169:26-27: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:171:29-37: Expected a type form, got instance of `Literal[0]` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:173:22-30: Expected a type form, got instance of `Literal[0]` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:173:41-42: Expected a type form, got instance of `TypeVar` [not-a-type]
- ERROR mypyc/test-data/fixtures/typing-full.pyi:174:22-23: Expected a type form, got instance of `TypeVar` [not-a-type]

... (truncated 15 lines) ...

paasta (https://github.com/yelp/paasta)
+ ERROR paasta_tools/bounce_lib.py:81:17-39: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:86:6-24: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:110:17-39: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:115:6-24: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:128:17-39: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:133:6-24: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:155:17-39: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:160:6-24: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:173:17-39: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/bounce_lib.py:178:6-24: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/drain_lib.py:263:16-23: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/drain_lib.py:264:24-31: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/drain_lib.py:265:22-29: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/drain_lib.py:266:26-33: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/drain_lib.py:304:45-52: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/frameworks/native_service_config.py:96:14-20: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/frameworks/native_service_config.py:97:15-22: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/frameworks/native_service_config.py:102:16-29: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/frameworks/native_service_config.py:103:14-25: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/generate_deployments_for_service.py:132:18-29: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/generate_deployments_for_service.py:227:77-88: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/generate_deployments_for_service.py:228:6-21: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/hacheck.py:39:40-49: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/hacheck.py:67:19-28: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/kubernetes_tools.py:227:26-54: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/kubernetes_tools.py:1379:19-47: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/kubernetes_tools.py:1386:17-45: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/kubernetes_tools.py:2346:22-40: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/kubernetes_tools.py:2454:17-30: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/mesos/master.py:301:41-53: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/metrics/metastatus_lib.py:86:14-26: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/metrics/metastatus_lib.py:122:14-26: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/metrics/metastatus_lib.py:159:14-26: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/metrics/metastatus_lib.py:197:14-26: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/metrics/metastatus_lib.py:434:14-26: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/metrics/metastatus_lib.py:463:14-26: Function call cannot be used in annotations [invalid-annotation]
+ ERROR paasta_tools/metrics/metastatus_lib.py:880:20-32: Function call cannot be used in annotations [invalid-annotation]

@github-actions
Copy link
Copy Markdown

Primer Diff Classification

❌ 1 regression(s) | ➖ 4 neutral | 5 project(s) total | +181, -144 errors

1 regression(s) across paasta. error kinds: invalid-annotation on mypy_extensions.TypedDict functional form. caused by classify_name_assign_type_form().

Project Verdict Changes Error Kinds Root Cause
bokeh ➖ Neutral +1, -1 invalid-annotation, not-a-type reports_implicit_alias_syntax_at_use_site()
pytest-autoprofile ➖ Neutral +1, -1 invalid-annotation, not-a-type classify_name_assign_type_form()
async-utils ➖ Neutral +28, -28 invalid-annotation on TypeVar from re-exported module classify_name_assign_type_form()
mypy ➖ Neutral +114, -114 New invalid-annotation errors on TypeVar usage in typing stubs classify_name_assign_type_form()
paasta ❌ Regression +37 invalid-annotation on mypy_extensions.TypedDict functional form classify_name_assign_type_form()
Detailed analysis

❌ Regression (1)

paasta (+37)

invalid-annotation on mypy_extensions.TypedDict functional form: All 37 errors flag uses of BounceMethodConfigDict and BounceMethodResult (created via mypy_extensions.TypedDict(...)) as annotations. These are functional-form TypedDict definitions that produce classes. Mypy (which owns mypy_extensions) accepts this pattern (0/37 cross-check), but pyright also flags all 37 errors (37/37 cross-check). The PR's exemption logic likely handles typing.TypedDict and typing_extensions.TypedDict but not mypy_extensions.TypedDict. Whether these are false positives depends on the desired compatibility target: they are false positives relative to mypy, but consistent with pyright's behavior.

Overall: The PR adds validation for implicit type aliases. All 37 errors flag uses of BounceMethodConfigDict and BounceMethodResult (created via mypy_extensions.TypedDict(...)) as annotations. These are functional-form TypedDict definitions that produce classes and are valid as type annotations. The cross-check shows 0/37 errors in mypy (which owns mypy_extensions and accepts this pattern), but 37/37 errors also appear in pyright. This means pyright also considers these invalid annotations, suggesting this is a known area of disagreement between type checkers. The PR's exemption logic likely handles typing.TypedDict and typing_extensions.TypedDict functional forms but does not cover mypy_extensions.TypedDict. Whether these are true false positives depends on the desired behavior: mypy accepts them, but pyright does not. If pyrefly aims for mypy compatibility here, these are false positives; if it follows pyright's stricter interpretation, they are expected.

Attribution: The new classify_name_assign_type_form() method in pyrefly/lib/alt/solve.rs flags function calls as invalid implicit aliases. The exemption in call_has_synthesized_runtime_type() only checks for synthesized ClassDef bindings and builtins.type calls, missing mypy_extensions.TypedDict which is a legitimate type-constructing call that pyrefly apparently doesn't synthesize a ClassDef for.

➖ Neutral (4)

bokeh (+1, -1)

This is a 1-for-1 error replacement: the old not-a-type error is removed and replaced by the new invalid-annotation error, both flagging the same real issue — ColorScheme (an Enumeration instance created by a function call) is not a valid type annotation. The error message changed but the detection capability is preserved. Net effect is neutral — same bug caught, different wording.
Attribution: The change in pyrefly/lib/alt/solve.rs added the classify_name_assign_type_form method and the check in reports_implicit_alias_syntax_at_use_site(). When a name used in an annotation resolves to a NameAssign binding whose RHS expression has invalid annotation syntax (like a function call), the new code now reports invalid-annotation at the use site instead of the previous not-a-type error. The annotation_syntax_problem() refactoring (extracted from has_valid_annotation_syntax()) enables this reuse.

pytest-autoprofile (+1, -1)

Without the source code, we must reason carefully. Line 81 likely contains something like X = TypeVar('X') or a similar TypeVar-producing call used in a type annotation context. The old error 'Expected a type form, got instance of TypeVar' suggests pyrefly was evaluating the TypeVar and finding it produces a TypeVar instance rather than a type form — this is a known category of diagnostic in type checkers. The new error 'Function call cannot be used in annotations' suggests the PR's changes now detect the TypeVar() call as a function call being used in an annotation position and reject it at an earlier stage. The change in behavior represents a shift in how the same construct is diagnosed. The new error is arguably less precise: TypeVar() is a special typing construct, not an arbitrary function call, so flagging it as 'Function call cannot be used in annotations' loses specificity. Whether either error is a true or false positive depends on the exact code context (which we don't have). If this is a simple TypeVar assignment like T = TypeVar('T') being used in annotations elsewhere, both errors would be false positives. If the TypeVar() call is being used directly in an annotation (e.g., x: TypeVar('T')), then both errors have some validity but the old error was more descriptive. The net effect is that the diagnostic message has become less informative and potentially more confusing, though without source code we cannot definitively classify either as a true or false positive.
Attribution: The new classify_name_assign_type_form() function in pyrefly/lib/alt/solve.rs and the check added in expr_annotation() (around line 5887 in the new code) that calls annotation_name_assign_type_form() are responsible. The TypeVar exemption in classify_name_assign_type_form() likely fails to fire because the call at line 81 doesn't resolve to a Type::TypeVar in pyrefly's type system (possibly due to how it's constructed or imported).

async-utils (+28, -28)

invalid-annotation on TypeVar from re-exported module: 28 new false positives at annotation use sites (e.g., -> T: in return types), NOT at the T = t.TypeVar('T') definition. Because from __future__ import annotations makes all annotations lazily evaluated strings, and T is defined via t.TypeVar('T') where t is a re-export module (from . import _typings as t), the type checker fails to resolve T as a proper TypeVar when used in annotations. It instead reports 'Function call cannot be used in annotations'. These replace 28 old false positives (not-a-type) at the same locations. Neither mypy nor pyright flags these. Net effect is neutral — both old and new errors are false positives on valid code.
removed not-a-type on TypeVar: 28 removed false positives at annotation use sites: 'Expected a type form, got instance of TypeVar' was wrong since TypeVar IS a valid type form in annotations. Removing these is correct, but they were replaced with different false positives (invalid-annotation) at the same locations.

Overall: This is a 1:1 swap of false positives. The old not-a-type errors were wrong (TypeVar instances are valid type forms in annotations), and the new invalid-annotation errors are equally wrong. However, the new errors are NOT on the T = t.TypeVar('T') definition lines — they are on the uses of T in return type annotations (e.g., async def __anext__(self) -> T: at line 46). Because from __future__ import annotations is present, annotations are evaluated as strings. The type checker apparently fails to resolve T — defined via t.TypeVar('T') where t is a re-export module (from . import _typings as t) — as a proper TypeVar when it appears in annotations, and instead reports it as an invalid annotation (function call in annotation). The old not-a-type errors were at the same annotation locations, saying 'Expected a type form, got instance of TypeVar', meaning the checker recognized T as a TypeVar but incorrectly rejected it as a type form. Both old and new errors are false positives on valid Python code. Neither mypy nor pyright reports errors at these locations (0/28 cross-check). The PR's improved handling of TypeVar resolved the not-a-type issue but introduced a different failure mode where the TypeVar defined through a re-exported module isn't properly recognized, causing the annotation-use sites to be flagged as invalid annotations instead. Net effect: no improvement, no regression — the error kind changed but the count and incorrectness are identical.

Attribution: The change in classify_name_assign_type_form() in pyrefly/lib/alt/solve.rs correctly exempts TypeVar/ParamSpec/TypeVarTuple by checking matches!(ty, Type::TypeVar(_) | ...), but this exemption fails when the TypeVar is imported through a re-export module (e.g., from . import _typings as t; T = t.TypeVar('T')). The type resolution through the intermediate module likely doesn't resolve to Type::TypeVar, so the exemption doesn't trigger, and the function call syntax check fires instead.

mypy (+114, -114)

New invalid-annotation errors on TypeVar usage in typing stubs: 114 new invalid-annotation errors flagging valid TypeVar usage (e.g., _T in def final(f: _T) -> _T) as 'Function call cannot be used in annotations'. These are false positives. The root cause is likely that _T is used on line 151 but defined on line 397 (_T = TypeVar('_T')), so pyrefly processes the annotation before recognizing _T as a TypeVar, instead treating it as an implicit type alias of a function call. 0/114 flagged by mypy, only 44/114 by pyright.
Removed not-a-type errors on TypeVar usage in typing stubs: 114 removed not-a-type errors like 'Expected a type form, got instance of TypeVar' were also false positives. TypeVar instances are valid type forms in annotations. Removing these is correct.

Overall: This is a regression. The PR introduces a new check for invalid implicit type aliases, but it incorrectly flags TypeVar usages in typing.pyi and typing-full.pyi as 'Function call cannot be used in annotations'. These are core typing stubs where _T = TypeVar('_T') is the standard pattern, and using _T in annotations like def final(f: _T) -> _T is completely valid. The PR has an exemption for TypeVar/ParamSpec/TypeVarTuple types, but it fails in the typing stubs. The likely cause is a forward-reference issue: _T is used on line 151 but _T = TypeVar('_T') is not defined until line 397, so when pyrefly processes line 151, it may not yet recognize _T as a TypeVar and instead sees it as an implicit type alias of a function call expression. The old not-a-type errors were also false positives, so removing those is good, but replacing them with equally wrong invalid-annotation errors is not an improvement. Net effect: 114 false positives removed, 114 different false positives added = no net improvement, and the new error message is arguably more confusing.

Attribution: The PR adds classify_name_assign_type_form() in pyrefly/lib/alt/solve.rs which checks if a name assignment's RHS has valid annotation syntax. The method annotation_syntax_problem() flags Expr::Call as 'Function call cannot be used in annotations'. In typing.pyi, lines like _T = TypeVar('_T') are name assignments where the RHS is a function call (TypeVar(...)). The PR has an exemption for TypeVar/ParamSpec/TypeVarTuple in classify_name_assign_type_form() (checking matches!(ty, Type::TypeVar(_) | Type::ParamSpec(_) | Type::TypeVarTuple(_))), but this exemption apparently doesn't work for all cases. Looking at line 151: def final(f: _T) -> _T: ... - here _T is used as an annotation. _T was defined on line 397 as _T = TypeVar('_T'). The TypeVar exemption should apply here, but the error still fires. Looking more carefully at the error locations - line 151 columns 14-16 and 21-23 correspond to _T in def final(f: _T) -> _T. Since _T = TypeVar('_T') is defined LATER on line 397, the PR's logic may be resolving _T before the TypeVar binding is established, causing the exemption check to fail. This is a bug in the PR's forward-reference handling for the typing stub's own TypeVar definitions.

Suggested fixes

Summary: The PR's new implicit alias validation flags mypy_extensions.TypedDict functional forms as invalid annotations because the exemption logic doesn't recognize them as synthesized class definitions, but all 37 errors are co-reported by pyright (0 are pyrefly-only).

1. In call_has_synthesized_runtime_type() in pyrefly/lib/alt/solve.rs, extend the check to also recognize calls to mypy_extensions.TypedDict as producing valid runtime types. Currently it only checks if the call's anonymous key resolves to a Binding::ClassDef, but pyrefly apparently doesn't synthesize a ClassDef for mypy_extensions.TypedDict calls. Either (a) ensure pyrefly synthesizes ClassDef bindings for mypy_extensions.TypedDict the same way it does for typing.TypedDict, or (b) add a fallback in call_has_synthesized_runtime_type() that checks if the callee resolves to a TypedDict constructor from any of typing/typing_extensions/mypy_extensions modules. For example: if the call target's qualified name matches 'mypy_extensions.TypedDict', return true.

Files: pyrefly/lib/alt/solve.rs
Confidence: medium
Affected projects: paasta
Fixes: invalid-annotation
The 37 new invalid-annotation errors in paasta all flag BounceMethodConfigDict and BounceMethodResult which are created via mypy_extensions.TypedDict(...). The exemption in call_has_synthesized_runtime_type() checks for Binding::ClassDef at the call's anonymous key, but pyrefly doesn't synthesize ClassDef for mypy_extensions.TypedDict. However, all 37 errors are also reported by pyright (0 are pyrefly-only), so this is consistent with pyright's stricter interpretation. The fix would align pyrefly with mypy's behavior for mypy_extensions.TypedDict. This would eliminate all 37 invalid-annotation errors in paasta.


Was this helpful? React with 👍 or 👎

Classification by primer-classifier (5 LLM)

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.

Conformance: Missing type alias validation

3 participants