Skip to content

[ty] Respect __new__ and metaclass __call__ return types#22317

Open
charliermarsh wants to merge 7 commits intomainfrom
charlie/metaclass
Open

[ty] Respect __new__ and metaclass __call__ return types#22317
charliermarsh wants to merge 7 commits intomainfrom
charlie/metaclass

Conversation

@charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Dec 31, 2025

Summary

Closes astral-sh/ty#281.
Closes astral-sh/ty#2288.
Closes astral-sh/ty#2641.
Closes astral-sh/ty#2712.

@charliermarsh charliermarsh added the ty Multi-file analysis & type inference label Dec 31, 2025
@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 31, 2025

Typing conformance results improved 🎉

The percentage of diagnostics emitted that were expected errors increased from 83.87% to 84.60%. The percentage of expected errors that received a diagnostic increased from 74.82% to 75.00%.

Summary

Metric Old New Diff Outcome
True Positives 811 813 +2 ⏫ (✅)
False Positives 156 148 -8 ⏬ (✅)
False Negatives 273 271 -2 ⏬ (✅)
Total Diagnostics 967 961 -6
Precision 83.87% 84.60% +0.73% ⏫ (✅)
Recall 74.82% 75.00% +0.18% ⏫ (✅)

True positives added

Details
Location Name Message
constructors_call_type.py:30:5 missing-argument No arguments provided for required parameters x, y of bound method __call__
constructors_call_type.py:72:5 missing-argument No arguments provided for required parameters x, y of bound method __call__

False positives removed

Details
Location Name Message
constructors_call_metaclass.py:39:1
constructors_call_metaclass.py:39:13
type-assertion-failure
missing-argument
Type int | Meta2 does not match asserted type Class2
No argument provided for required parameter x of function __new__
constructors_call_new.py:49:1
constructors_call_new.py:49:13
type-assertion-failure
missing-argument
Type int does not match asserted type Class3
No argument provided for required parameter x of bound method __init__
constructors_call_new.py:64:1
constructors_call_new.py:64:13
type-assertion-failure
missing-argument
Type Class4 | Any does not match asserted type Class4
No argument provided for required parameter x of bound method __init__
constructors_call_new.py:89:1
constructors_call_new.py:89:13
type-assertion-failure
missing-argument
Type int | Class6 does not match asserted type Class6
No argument provided for required parameter x of bound method __init__

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 31, 2025

mypy_primer results

Changes were detected when running on open source projects
spack (https://github.com/spack/spack)
- lib/spack/spack/cmd/compiler.py:94:16: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `reversed[str]`
+ lib/spack/spack/cmd/compiler.py:94:16: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `Iterator[str]`
- lib/spack/spack/cmd/compiler.py:112:16: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `reversed[str]`
+ lib/spack/spack/cmd/compiler.py:112:16: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `Iterator[str]`
- lib/spack/spack/cmd/compiler.py:123:12: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `reversed[str]`
+ lib/spack/spack/cmd/compiler.py:123:12: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `Iterator[str]`
- lib/spack/spack/cmd/compiler.py:219:16: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `reversed[Unknown]`
+ lib/spack/spack/cmd/compiler.py:219:16: error[invalid-argument-type] Argument to function `colify` is incorrect: Expected `list[Any]`, found `Iterator[Unknown]`
- lib/spack/spack/detection/path.py:169:33: error[invalid-argument-type] Argument to function `dedupe_paths` is incorrect: Expected `list[str]`, found `Unknown | list[str | bytes | PathLike[str] | ... omitted 3 union elements]`
+ lib/spack/spack/detection/path.py:169:33: error[invalid-argument-type] Argument to function `dedupe_paths` is incorrect: Expected `list[str]`, found `Unknown | list[int | Unknown | str | ... omitted 3 union elements]`
+ lib/spack/spack/llnl/util/lang.py:264:16: error[unsupported-operator] Operator `<` is not supported between two objects of type `~None`
+ lib/spack/spack/test/spec_syntax.py:1718:16: error[unsupported-operator] Operator `<=` is not supported between two objects of type `Unknown | Spec | None`
+ lib/spack/spack/test/spec_syntax.py:1718:26: error[unsupported-operator] Operator `<` is not supported between two objects of type `Unknown | Spec | None`
- Found 4382 diagnostics
+ Found 4385 diagnostics

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/filter.py:41:13: error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal["plugins"]` and `type`
+ src/bandersnatch/filter.py:42:33: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/filter.py:46:25: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/filter.py:103:16: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/filter.py:107:16: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/filter.py:170:30: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/main.py:222:23: error[unresolved-attribute] Object of type `type` has no attribute `get`
+ src/bandersnatch/main.py:228:41: error[invalid-argument-type] Argument to function `async_main` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/storage.py:70:31: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/storage.py:79:17: error[unresolved-attribute] Attribute `get` is not defined on `type` in union `ConfigParser | type`
+ src/bandersnatch/storage.py:88:25: error[unresolved-attribute] Attribute `getint` is not defined on `type` in union `ConfigParser | type`
+ src/bandersnatch/storage.py:110:20: error[unresolved-attribute] Attribute `get` is not defined on `type` in union `Unknown | ConfigParser | type`
+ src/bandersnatch/storage.py:343:18: error[invalid-assignment] Object of type `type` is not assignable to `ConfigParser | None`
+ src/bandersnatch/storage.py:346:30: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ src/bandersnatch/tests/mock_config.py:15:5: error[unresolved-attribute] Object of type `type` has no attribute `clear`
+ src/bandersnatch/tests/mock_config.py:17:5: error[unresolved-attribute] Object of type `type` has no attribute `_read_defaults_file`
+ src/bandersnatch/tests/mock_config.py:19:5: error[unresolved-attribute] Object of type `type` has no attribute `read_string`
+ src/bandersnatch/tests/mock_config.py:20:12: error[invalid-return-type] Return type does not match returned value: expected `BandersnatchConfig`, found `type`
+ src/bandersnatch/tests/test_configuration.py:54:36: error[unresolved-attribute] Object of type `type` has no attribute `sections`
+ src/bandersnatch/tests/test_configuration.py:58:41: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:109:29: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:114:9: error[unresolved-attribute] Object of type `type` has no attribute `read_string`
+ src/bandersnatch/tests/test_configuration.py:116:26: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:120:9: error[unresolved-attribute] Object of type `type` has no attribute `read_string`
+ src/bandersnatch/tests/test_configuration.py:122:30: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:126:9: error[unresolved-attribute] Object of type `type` has no attribute `read_string`
+ src/bandersnatch/tests/test_configuration.py:128:26: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:132:9: error[unresolved-attribute] Object of type `type` has no attribute `read_string`
+ src/bandersnatch/tests/test_configuration.py:136:26: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:156:52: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_configuration.py:176:9: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
- src/bandersnatch/tests/test_configuration.py:109:29: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc`, found `str | None`
+ src/bandersnatch/tests/test_configuration.py:178:52: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_configuration.py:200:9: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:206:52: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_configuration.py:227:9: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:228:68: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_configuration.py:248:9: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:249:68: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_configuration.py:254:9: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch/tests/test_configuration.py:256:36: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_configuration.py:264:12: error[unresolved-attribute] Object of type `type` has no attribute `has_option`
+ src/bandersnatch/tests/test_configuration.py:265:13: error[unresolved-attribute] Object of type `type` has no attribute `remove_option`
+ src/bandersnatch/tests/test_configuration.py:266:41: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_configuration.py:321:17: error[unresolved-attribute] Object of type `type` has no attribute `read_dict`
+ src/bandersnatch/tests/test_configuration.py:322:56: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_delete.py:83:5: error[unresolved-attribute] Object of type `type` has no attribute `read_dict`
+ src/bandersnatch/tests/test_filter.py:122:9: error[unresolved-attribute] Object of type `type` has no attribute `read_string`
+ src/bandersnatch/tests/test_mirror.py:1251:5: error[unresolved-attribute] Object of type `type` has no attribute `read_dict`
+ src/bandersnatch/tests/test_mirror.py:1287:22: error[invalid-argument-type] Argument to function `mirror` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_mirror.py:1334:5: error[unresolved-attribute] Object of type `type` has no attribute `read_dict`
+ src/bandersnatch/tests/test_mirror.py:1372:22: error[invalid-argument-type] Argument to function `mirror` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch/tests/test_simple.py:50:37: error[invalid-argument-type] Argument to function `validate_config_values` is incorrect: Expected `ConfigParser`, found `type`
+ src/bandersnatch_filter_plugins/latest_name.py:30:29: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/latest_name.py:38:23: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/metadata_filter.py:36:36: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/metadata_filter.py:36:36: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/metadata_filter.py:198:38: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/metadata_filter.py:271:36: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/prerelease_name.py:40:25: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/regex_name.py:26:22: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_filter_plugins/regex_name.py:60:22: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_storage_plugins/filesystem.py:28:35: error[unresolved-attribute] Attribute `getboolean` is not defined on `type` in union `Unknown | ConfigParser | type`
+ src/bandersnatch_storage_plugins/s3.py:139:21: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_storage_plugins/s3.py:159:25: error[not-subscriptable] Cannot subscript object of type `type` with no `__class_getitem__` method
+ src/bandersnatch_storage_plugins/s3.py:163:43: error[unresolved-attribute] Attribute `get` is not defined on `type` in union `Unknown | ConfigParser | type`
- Found 66 diagnostics
+ Found 130 diagnostics

graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/type/definition.py:438:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLScalarType`, found `GraphQLNamedType`
+ src/graphql/type/definition.py:768:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLObjectType`, found `GraphQLNamedType`
+ src/graphql/type/definition.py:872:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInterfaceType`, found `GraphQLNamedType`
+ src/graphql/type/definition.py:975:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLUnionType`, found `GraphQLNamedType`
+ src/graphql/type/definition.py:1110:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLEnumType`, found `GraphQLNamedType`
+ src/graphql/type/definition.py:1342:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInputObjectType`, found `GraphQLNamedType`
+ src/graphql/type/directives.py:159:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/directives.py:176:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/directives.py:191:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/directives.py:195:34: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/directives.py:207:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/directives.py:211:34: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/directives.py:213:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/directives.py:234:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/directives.py:252:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:48:41: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:103:30: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLObjectType`
+ src/graphql/type/introspection.py:118:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:122:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:126:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:137:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:170:33: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLObjectType`
+ src/graphql/type/introspection.py:183:39: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLEnumType`
+ src/graphql/type/introspection.py:272:34: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:273:41: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:274:44: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:279:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:295:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:304:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:310:37: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:405:28: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLObjectType`
+ src/graphql/type/introspection.py:424:49: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:425:41: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:430:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:437:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:441:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:475:29: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLObjectType`
+ src/graphql/type/introspection.py:487:49: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:489:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:493:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:499:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:503:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:536:34: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLObjectType`
+ src/graphql/type/introspection.py:549:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:552:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:555:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:559:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ src/graphql/type/introspection.py:580:33: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLObjectType`
+ src/graphql/type/introspection.py:603:30: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLEnumType`
+ src/graphql/type/introspection.py:672:50: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/introspection.py:678:20: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ src/graphql/type/scalars.py:307:59: error[invalid-assignment] Object of type `dict[str, GraphQLNamedType]` is not assignable to `Mapping[str, GraphQLScalarType]`
+ src/graphql/utilities/build_client_schema.py:155:20: error[invalid-return-type] Return type does not match returned value: expected `GraphQLScalarType`, found `GraphQLNamedType`
+ src/graphql/utilities/build_client_schema.py:186:20: error[invalid-return-type] Return type does not match returned value: expected `GraphQLObjectType`, found `GraphQLNamedType`
+ src/graphql/utilities/build_client_schema.py:196:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInterfaceType`, found `GraphQLNamedType`
+ src/graphql/utilities/build_client_schema.py:216:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLUnionType`, found `GraphQLNamedType`
+ src/graphql/utilities/build_client_schema.py:233:20: error[invalid-return-type] Return type does not match returned value: expected `GraphQLEnumType`, found `GraphQLNamedType`
+ src/graphql/utilities/build_client_schema.py:255:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInputObjectType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:352:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInputObjectType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:367:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLEnumType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:384:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLScalarType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:418:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLObjectType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:457:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInterfaceType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:482:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLUnionType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:683:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLObjectType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:702:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInterfaceType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:718:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLEnumType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:733:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLUnionType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:746:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLScalarType`, found `GraphQLNamedType`
+ src/graphql/utilities/extend_schema.py:763:16: error[invalid-return-type] Return type does not match returned value: expected `GraphQLInputObjectType`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_async.py:14:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_async.py:15:30: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_async.py:28:5: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_async.py:32:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_sync.py:12:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_sync.py:13:30: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_sync.py:26:5: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/benchmarks/test_execution_sync.py:30:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/benchmarks/test_repeated_fields.py:10:5: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/benchmarks/test_repeated_fields.py:14:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:96:70: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:101:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:102:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:111:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:112:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:119:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:160:70: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:165:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:166:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:175:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:176:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:183:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:231:70: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:236:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:237:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:244:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:283:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:284:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:292:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:293:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:301:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:344:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:351:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:352:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:360:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:361:39: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_abstract.py:367:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:17:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:17:61: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:33:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:35:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:79:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:79:67: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:80:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:81:54: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:123:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:123:67: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:124:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_customize.py:128:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:42:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:43:30: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:44:52: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_defer.py:59:29: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:60:29: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:61:29: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:62:29: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:68:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:68:72: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:72:58: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:86:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:87:58: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_defer.py:94:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:101:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:102:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:109:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:110:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:117:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:124:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:125:30: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:126:52: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_defer.py:128:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:129:45: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:135:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:135:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:135:79: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_defer.py:138:24: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_directives.py:6:5: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_directives.py:7:40: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_directives.py:7:74: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:42:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:44:36: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:103:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:104:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:105:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:106:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:107:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:108:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:110:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:111:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:115:41: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:119:24: error[invalid-assignment] Object of type `GraphQLNamedType` is not assignable to `GraphQLObjectType`
+ tests/execution/test_executor.py:122:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:123:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:162:27: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:195:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:196:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:197:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:198:38: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:201:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:241:43: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:244:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:260:13: error[invalid-argument-type] Argument is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:260:13: error[invalid-argument-type] Argument is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:283:49: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:292:63: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_executor.py:296:32: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:336:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:337:44: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:355:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:359:25: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:361:55: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:362:58: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown] | GraphQLNonNull[GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList[Unknown]]`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:402:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:405:44: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:406:47: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:407:50: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:408:53: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:410:45: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:411:48: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:412:62: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:413:51: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:414:54: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:415:68: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:534:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:538:40: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_executor.py:541:40: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_executor.py:581:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:585:40: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_executor.py:587:48: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:630:43: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:631:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_executor.py:632:55: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Argument type `GraphQLNamedType` does not satisfy upper bound `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements` of type variable `GNT_co`
+ tests/execution/test_executor.py:637:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:638:61: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:671:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:671:58: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | ... omitted 4 union elements`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:684:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLObjectType | None`, found `GraphQLNamedType`
+ tests/execution/test_executor.py:684:58: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `GraphQLScalarType | G

... (truncated 6652 lines) ...

@charliermarsh
Copy link
Member Author

(Needs work, intentionally in draft, not ready for review.)

@charliermarsh
Copy link
Member Author

Hmm, I think the bandersnatch diagnostics are technically correct? It uses a singleton:

class Singleton(type):  # pragma: no cover
    _instances: dict["Singleton", type] = {}

    def __call__(cls, *args: Any, **kwargs: Any) -> type:
        if cls not in cls._instances:
            cls._instances[cls] = super().__call__(*args, **kwargs)
        return cls._instances[cls]

But the return type is not type, it's an instance?

Mypy seems to ignore it, and Pyright seemingly synthesizes a return type type[__class_type]?

@charliermarsh
Copy link
Member Author

@charliermarsh
Copy link
Member Author

I think our behavior here is "correct" but it's stricter than mypy or pyright. Here are two examples (from bandersnatch and graphql-core respectively).

For bandersnatch:

class Singleton(type):
    def __call__(cls, *args, **kwargs) -> type:
        ...

class Config(metaclass=Singleton): ...

Config().method()  # ty: error (type has no method)

Meanwhile mypy and pyright both allow this.

For graphql-core:

class Base:
    def __new__(cls, name: str) -> "Base":  # should be -> Self
        return super().__new__(cls)

class Derived(Base):
    def __copy__(self) -> "Derived":
        return self.__class__("test")  # ty: error (returns Base)

Again, mypy and pyright both allow this.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 31, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
type-assertion-failure 201 901 764
invalid-argument-type 1,184 22 160
unresolved-attribute 1,028 12 94
unsupported-operator 181 24 130
no-matching-overload 107 36 9
unused-type-ignore-comment 16 62 0
invalid-return-type 61 2 2
invalid-assignment 51 3 5
not-subscriptable 31 0 0
invalid-key 10 0 0
missing-argument 3 7 0
too-many-positional-arguments 9 1 0
call-non-callable 9 0 0
redundant-cast 3 4 0
not-iterable 1 0 3
possibly-missing-attribute 0 3 0
unresolved-reference 0 3 0
assert-type-unspellable-subtype 0 0 1
invalid-parameter-default 1 0 0
unknown-argument 1 0 0
Total 2,897 1,080 1,168

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as draft January 21, 2026 04:25
@charliermarsh charliermarsh force-pushed the charlie/metaclass branch 4 times, most recently from c7c97d2 to 76341b9 Compare January 21, 2026 22:37
@charliermarsh charliermarsh marked this pull request as ready for review January 22, 2026 20:43
@AlexWaygood AlexWaygood removed the request for review from MichaReiser January 22, 2026 20:47
Copy link
Member

@dcreager dcreager left a comment

Choose a reason for hiding this comment

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

I think our behavior here is "correct" but it's stricter than mypy or pyright. Here are two examples (from bandersnatch and graphql-core respectively).

We have an instance of this in our test suite, too:

class C(Generic[T, U]):
def __new__(cls, *args, **kwargs) -> "C[T, U]":
return object.__new__(cls)

According to the spec, that should return Self.

@carljm
Copy link
Contributor

carljm commented Jan 27, 2026

Just to double-check: the algorithm we should be following here is documented in detail at https://typing.python.org/en/latest/spec/constructors.html -- is that what this PR aims to implement?

@charliermarsh charliermarsh marked this pull request as draft February 12, 2026 15:04
@charliermarsh charliermarsh force-pushed the charlie/metaclass branch 3 times, most recently from 5ea389f to fa2ce9f Compare February 12, 2026 17:27
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 12, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@charliermarsh charliermarsh marked this pull request as ready for review February 12, 2026 17:41
@carljm carljm self-assigned this Feb 14, 2026
@carljm carljm self-requested a review February 15, 2026 06:58
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Tests are looking good! I unresolved a couple minor comments from my previous review that were marked resolved but look like they weren't addressed?

I did a quick scan of the code and found some issues with the handling of mixed instance/non-instance metaclass __call__ and __new__, and with the way method-generic __new__ is currently handled, that I think are going to require a pretty significant rework of the approach here.

// Fall back to restricting the inferred specialization to class-level type
// variables.
let specialization = class_literal
.and_then(|lit| overload.return_ty.specialization_of(db, lit))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is right. It seems very oriented around specializing the class literal of the type on which __new__ is defined, but that's overfitting the one example case I gave (which is the typical case, to be fair.) This should be fully general, e.g. this works on other type-checkers but on this branch reveals just C:

class C:
    def __new__[S](cls, x: S) -> S:
        return x

reveal_type(C("foo"))

And it should work just as well if the return type of __new__ is something like list[S] or whatever.

.iter()
.flat_map(|callable_binding| callable_binding.overloads().iter())
.map(|overload| overload.signature.return_ty)
.find(|return_ty| {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this logic matches what is specified. The spec talks about the evaluated return type of __new__, which includes evaluating overloads at the actual call site. That is, given this class:

from typing import overload, Self

class C:
    @overload
    def __new__(cls, x: int) -> int: ...
    @overload
    def __new__(cls, x: str) -> Self: ...
    def __new__(cls, x: int | str) -> object: ...

    def __init__(self) -> None: ...

reveal_type(C(1))  # revealed: int
# should error (expected zero arguments to `__init__`) but this PR doesn't
reveal_type(C("foo"))  # should reveal C, we reveal int

A call that matches the first overload does not return an instance of C, and therefore skips __init__, but a call that matches the second overload does return an instance of C, and should not skip __init__ -- and more importantly should not be inferred as returning int!

In other words, we can't make the decision whether it is an instance or non-instance return type here in bindings -- we need to preserve enough information in bindings to make this decision in call checking. (This might involve more special-casing of constructor bindings, since they effectively need to preserve multiple bindings until call time?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Gave this a shot!

Comment on lines 4883 to 4884
// Mixed: save non-instance overloads (pre-bound, removing `cls`) for
// later combination with `__init__` overloads.
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the comment below, I don't think this approach works. The parallel example here would be:

from typing import overload

class M(type):
    @overload
    def __call__(self, x: int) -> int: ...
    @overload
    def __call__(self, x: str) -> "C": ...
    def __call__(self, x: int | str) -> object: ...

class C(metaclass=M):
    def __init__(self) -> None: ...

reveal_type(C(1))  # revealed: int
# should error due to __init__ expecting zero args; we error because we drop
# the second overload and don't even see `str` as a valid argument type?
reveal_type(C("foo"))  # should reveal C, we reveal Unknown

@charliermarsh charliermarsh marked this pull request as draft February 15, 2026 19:23
@charliermarsh charliermarsh force-pushed the charlie/metaclass branch 2 times, most recently from 5b3ecfc to d07bf14 Compare February 15, 2026 22:32
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 15, 2026

Merging this PR will degrade performance by 9.43%

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 51 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime static_frame 30 s 33.2 s -9.43%
WallTime pandas 78.7 s 85.1 s -7.48%
WallTime freqtrade 9 s 7.9 s +14.45%

Comparing charlie/metaclass (e4c4fb3) with main (b243865)

Open in CodSpeed

@charliermarsh charliermarsh marked this pull request as ready for review February 16, 2026 03:43
@charliermarsh
Copy link
Member Author

(I will resolve the regression assuming the new approach looks broadly better.)

@carljm carljm self-requested a review February 16, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

3 participants