Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood added ty Multi-file analysis & type inference diagnostics Related to reporting of diagnostics. labels Dec 3, 2025
@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 3, 2025

Diagnostic diff on typing conformance tests

Changes were detected when running ty on typing conformance tests
--- old-output.txt	2025-12-03 17:36:22.183723401 +0000
+++ new-output.txt	2025-12-03 17:36:25.927749245 +0000
@@ -915,7 +915,7 @@
 specialtypes_type.py:120:5: error[unresolved-attribute] Object of type `type` has no attribute `unknown`
 specialtypes_type.py:137:5: error[type-assertion-failure] Type `type[Any]` does not match asserted type `type`
 specialtypes_type.py:139:5: error[type-assertion-failure] Type `type[Any]` does not match asserted type `type`
-specialtypes_type.py:143:1: error[unresolved-attribute] Object of type `typing.Type` has no attribute `unknown`
+specialtypes_type.py:143:1: error[unresolved-attribute] Special form `typing.Type` has no attribute `unknown`
 specialtypes_type.py:145:1: error[unresolved-attribute] Class `type` has no attribute `unknown`
 specialtypes_type.py:169:21: error[invalid-assignment] Object of type `type` is not assignable to `type[int]`
 specialtypes_type.py:175:16: error[invalid-return-type] Return type does not match returned value: expected `type[T@ClassA]`, found `type`

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 3, 2025

mypy_primer results

Changes were detected when running on open source projects
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/transactions.py:349:48: error[unresolved-attribute] Object of type `typing.Self` has no attribute `commit`
+ src/prefect/transactions.py:349:48: error[unresolved-attribute] Special form `typing.Self` has no attribute `commit`
- src/prefect/transactions.py:350:38: error[unresolved-attribute] Object of type `typing.Self` has no attribute `commit`
+ src/prefect/transactions.py:350:38: error[unresolved-attribute] Special form `typing.Self` has no attribute `commit`
- src/prefect/transactions.py:352:21: error[unresolved-attribute] Object of type `typing.Self` has no attribute `commit`
+ src/prefect/transactions.py:352:21: error[unresolved-attribute] Special form `typing.Self` has no attribute `commit`
- src/prefect/transactions.py:429:48: error[unresolved-attribute] Object of type `typing.Self` has no attribute `rollback`
+ src/prefect/transactions.py:429:48: error[unresolved-attribute] Special form `typing.Self` has no attribute `rollback`
- src/prefect/transactions.py:430:38: error[unresolved-attribute] Object of type `typing.Self` has no attribute `rollback`
+ src/prefect/transactions.py:430:38: error[unresolved-attribute] Special form `typing.Self` has no attribute `rollback`
- src/prefect/transactions.py:432:21: error[unresolved-attribute] Object of type `typing.Self` has no attribute `rollback`
+ src/prefect/transactions.py:432:21: error[unresolved-attribute] Special form `typing.Self` has no attribute `rollback`
- src/prefect/transactions.py:512:21: error[unresolved-attribute] Object of type `typing.Self` has no attribute `commit`
+ src/prefect/transactions.py:512:21: error[unresolved-attribute] Special form `typing.Self` has no attribute `commit`
- src/prefect/transactions.py:592:21: error[unresolved-attribute] Object of type `typing.Self` has no attribute `rollback`
+ src/prefect/transactions.py:592:21: error[unresolved-attribute] Special form `typing.Self` has no attribute `rollback`

xarray (https://github.com/pydata/xarray)
- xarray/core/treenode.py:654:13: error[unresolved-attribute] Object of type `typing.Self` has no attribute `orphan`
+ xarray/core/treenode.py:654:13: error[unresolved-attribute] Special form `typing.Self` has no attribute `orphan`

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_typing.pyi:1209:16: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 5511 diagnostics
+ Found 5512 diagnostics

pydantic (https://github.com/pydantic/pydantic)
- pydantic/fields.py:943:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:943:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:983:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:983:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1026:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1026:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1066:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1066:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1109:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1109:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1148:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1148:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1188:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1188:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1567:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`
+ pydantic/fields.py:1567:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`

No memory usage changes detected ✅

@AlexWaygood
Copy link
Member Author

The ecosystem impact seems fine. Those Self diagnostics are false positives related to astral-sh/ty#1124, but this PR doesn't make the error messages any worse for them, and it's unlikely any of the detailed subdiagnostics I'm adding will fire on any of them.

Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Cool — thank you!

Comment on lines +9115 to +9121
fn is_dotted_name(attribute: &ast::Expr) -> bool {
match attribute {
ast::Expr::Name(_) => true,
ast::Expr::Attribute(ast::ExprAttribute { value, .. }) => is_dotted_name(value),
_ => false,
}
}
Copy link
Contributor

@sharkdp sharkdp Dec 3, 2025

Choose a reason for hiding this comment

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

Is it worth reusing this (also used in is_if_type_checking)? Fine if not, it's short enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'll pass -- it's a tiny routine, and semantic_index/builder.rs feels like a long way away from this code.

Comment on lines +9232 to +9236
maybe_n = if attr_name.starts_with(['a', 'e', 'i', 'o', 'u']) {
"n"
} else {
""
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🥇

@AlexWaygood AlexWaygood merged commit 8ebecb2 into main Dec 3, 2025
41 checks passed
@AlexWaygood AlexWaygood deleted the alex/special-form-attr-hint branch December 3, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics Related to reporting of diagnostics. ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perplexing "Object of type typing.Any has no attribute"

3 participants