Skip to content

Use types.FunctionType instead of builtins.function - #22538

Draft
hamdanal wants to merge 1 commit into
python:masterfrom
hamdanal:types.FunctionType
Draft

hamdanal wants to merge 1 commit into
python:masterfrom
hamdanal:types.FunctionType

Conversation

@hamdanal

Copy link
Copy Markdown
Collaborator

Fixes #8240

Unblocks python/typeshed#14957 (cc @srittau)

@github-actions

Copy link
Copy Markdown
Contributor

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

spark (https://github.com/apache/spark)
+ python/pyspark/sql/pandas/group_ops.py:738: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/sql/pandas/group_ops.py:745: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/sql/pandas/functions.pyi:108: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/sql/pandas/functions.pyi:110: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/sql/pandas/functions.pyi:112: error: Unused "type: ignore" comment  [unused-ignore]

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/tasks.py:304: error: "Callable[..., Any]" not callable  [operator]

strawberry (https://github.com/strawberry-graphql/strawberry)
+ strawberry/pydantic/resolver_field.py:134: error: Unused "type: ignore" comment  [unused-ignore]

colour (https://github.com/colour-science/colour)
- colour/colorimetry/tests/test_tristimulus_values.py:2118: error: Cannot call function of unknown type  [operator]
- colour/colorimetry/tests/test_tristimulus_values.py:2131: error: Cannot call function of unknown type  [operator]
- colour/colorimetry/tests/test_tristimulus_values.py:2167: error: Cannot call function of unknown type  [operator]
- colour/colorimetry/tests/test_tristimulus_values.py:2180: error: Cannot call function of unknown type  [operator]

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/commands/__init__.py:935: error: Item "function" of "Callable[P, T] | None" has no attribute "_pwndbg_only_when_running_allow_core"  [union-attr]
+ pwndbg/commands/__init__.py:935: error: Item "FunctionType" of "Callable[P, T] | None" has no attribute "_pwndbg_only_when_running_allow_core"  [union-attr]

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/response.py:1349: error: Unused "type: ignore" comment  [unused-ignore]
+ src/urllib3/response.py:1349: error: Incompatible return value type (got "MethodType", expected "bool")  [return-value]
+ src/urllib3/response.py:1349: note: Error code "return-value" not covered by "type: ignore[no-any-return]" comment

core (https://github.com/home-assistant/core)
+ homeassistant/components/template/image.py:149: error: Incompatible return value type (got "MethodType", expected "str | None")  [return-value]
+ homeassistant/components/template/image.py:174: error: Incompatible return value type (got "MethodType", expected "str | None")  [return-value]
+ homeassistant/components/zha/device_tracker.py:71: error: Incompatible return value type (got "MethodType", expected "DeviceInfo")  [return-value]
+ homeassistant/components/zha/device_tracker.py:78: error: Incompatible return value type (got "MethodType", expected "str")  [return-value]

egglog-python (https://github.com/egraphs-good/egglog-python)
+ python/egglog/egraph.py:1759: error: Redundant cast to "Action | BaseExpr | Fact | RewriteOrRule"  [redundant-cast]

discord.py (https://github.com/Rapptz/discord.py)
- discord/app_commands/commands.py:244: error: Item "function" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[str]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[str]]]]" has no attribute "pass_command_binding"  [union-attr]
+ discord/app_commands/commands.py:244: error: Item "FunctionType" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[str]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[str]]]]" has no attribute "pass_command_binding"  [union-attr]
- discord/app_commands/commands.py:244: error: Item "function" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[int]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[int]]]]" has no attribute "pass_command_binding"  [union-attr]
+ discord/app_commands/commands.py:244: error: Item "FunctionType" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[int]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[int]]]]" has no attribute "pass_command_binding"  [union-attr]
- discord/app_commands/commands.py:244: error: Item "function" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[float]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[float]]]]" has no attribute "pass_command_binding"  [union-attr]
+ discord/app_commands/commands.py:244: error: Item "FunctionType" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[float]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[float]]]]" has no attribute "pass_command_binding"  [union-attr]
- discord/app_commands/commands.py:244: error: Item "function" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[str | int | float]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[str | int | float]]]]" has no attribute "pass_command_binding"  [union-attr]
+ discord/app_commands/commands.py:244: error: Item "FunctionType" of "Callable[[GroupT, Interaction[Any], str], Coroutine[Any, Any, list[Choice[str | int | float]]]] | Callable[[Interaction[Any], str], Coroutine[Any, Any, list[Choice[str | int | float]]]]" has no attribute "pass_command_binding"  [union-attr]
- discord/app_commands/commands.py:692: error: Item "function" of "Callable[[GroupT, Interaction[Any], **P], Coroutine[Any, Any, T]] | Callable[[Interaction[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__self__"  [union-attr]
- discord/app_commands/commands.py:693: error: Item "function" of "Callable[[GroupT, Interaction[Any], **P], Coroutine[Any, Any, T]] | Callable[[Interaction[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__func__"  [union-attr]
+ discord/app_commands/commands.py:692: error: Item "FunctionType" of "Callable[[GroupT, Interaction[Any], **P], Coroutine[Any, Any, T]] | Callable[[Interaction[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__self__"  [union-attr]
+ discord/app_commands/commands.py:693: error: Item "FunctionType" of "Callable[[GroupT, Interaction[Any], **P], Coroutine[Any, Any, T]] | Callable[[Interaction[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__func__"  [union-attr]
- discord/ext/commands/core.py:462: error: Item "function" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__commands_checks__"  [union-attr]
+ discord/ext/commands/core.py:462: error: Item "FunctionType" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__commands_checks__"  [union-attr]
- discord/ext/commands/core.py:470: error: Item "function" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__commands_cooldown__"  [union-attr]
+ discord/ext/commands/core.py:470: error: Item "FunctionType" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__commands_cooldown__"  [union-attr]
- discord/ext/commands/core.py:483: error: Item "function" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__commands_max_concurrency__"  [union-attr]
+ discord/ext/commands/core.py:483: error: Item "FunctionType" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__commands_max_concurrency__"  [union-attr]
- discord/ext/commands/core.py:500: error: Item "function" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__before_invoke__"  [union-attr]
- discord/ext/commands/core.py:508: error: Item "function" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__after_invoke__"  [union-attr]
+ discord/ext/commands/core.py:500: error: Item "FunctionType" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__before_invoke__"  [union-attr]
+ discord/ext/commands/core.py:508: error: Item "FunctionType" of "Callable[[CogT, Context[Any], **P], Coroutine[Any, Any, T]] | Callable[[Context[Any], **P], Coroutine[Any, Any, T]]" has no attribute "__after_invoke__"  [union-attr]
- discord/ext/commands/hybrid.py:378: error: Item "function" of "def (CogT, Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T] | def (Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T]" has no attribute "__signature__"  [union-attr]
+ discord/ext/commands/hybrid.py:378: error: Item "FunctionType" of "def (CogT, Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T] | def (Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T]" has no attribute "__signature__"  [union-attr]
- discord/ext/commands/hybrid.py:388: error: Item "function" of "def (CogT, Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T] | def (Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T]" has no attribute "__signature__"  [union-attr]
+ discord/ext/commands/hybrid.py:388: error: Item "FunctionType" of "def (CogT, Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T] | def (Context[Any], /, *Any, **Any) -> Coroutine[Any, Any, T]" has no attribute "__signature__"  [union-attr]

pandera (https://github.com/pandera-dev/pandera)
+ pandera/typing/pandas.py:240: error: Unused "type: ignore" comment  [unused-ignore]
+ pandera/typing/pandas.py:278: error: Unused "type: ignore" comment  [unused-ignore]
+ tests/pandas/test_decorators.py:462: error: Unused "type: ignore" comment  [unused-ignore]
+ tests/pandas/test_decorators.py:475: error: Unused "type: ignore" comment  [unused-ignore]
- tests/cli/test_cli.py:613: error: Cannot call function of unknown type  [operator]

dulwich (https://github.com/dulwich/dulwich)
+ dulwich/porcelain/__init__.py:3903: error: Unused "type: ignore" comment  [unused-ignore]

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_decorators.py:152: error: Incompatible return value type (got "def (*Any, **Any) -> ReturnType | Any | property", expected "PydanticDescriptorProxy[ReturnType]")  [return-value]
+ pydantic/_internal/_decorators.py:152: error: Incompatible return value type (got "def (*Any, **Any) -> ReturnType | MethodType | Any | property", expected "PydanticDescriptorProxy[ReturnType]")  [return-value]
+ pydantic/validate_call_decorator.py:116: error: Unused "type: ignore" comment  [unused-ignore]
- pydantic/experimental/arguments_schema.py:47: error: Argument 1 to "_arguments_schema" of "GenerateSchema" has incompatible type "Callable[..., Any]"; expected "FunctionType | MethodType | partial[Any]"  [arg-type]
- pydantic/experimental/arguments_schema.py:49: error: Argument 1 to "_arguments_v3_schema" of "GenerateSchema" has incompatible type "Callable[..., Any]"; expected "FunctionType | MethodType | partial[Any]"  [arg-type]

scipy (https://github.com/scipy/scipy)
- scipy/stats/tests/test_sampling.py:528: error: Argument 1 to "__iadd__" of "list" has incompatible type "list[tuple[function, type[Exception], str]]"; expected "Iterable[tuple[Callable[[Any], int], type[UNURANError], str]]"  [arg-type]
+ scipy/stats/tests/test_sampling.py:528: error: Argument 1 to "__iadd__" of "list" has incompatible type "list[tuple[FunctionType, type[Exception], str]]"; expected "Iterable[tuple[Callable[[Any], int], type[UNURANError], str]]"  [arg-type]

pytest-autoprofile (https://gitlab.com/TTsangSC/pytest-autoprofile)
+ src/pytest_autoprofile/profiler.py:560: error: Unused "type: ignore" comment  [unused-ignore]
+ src/pytest_autoprofile/profiler.py:602: error: Overloaded function signature 10 will never be matched: signature 3's parameter type(s) are the same or broader  [overload-cannot-match]
+ src/pytest_autoprofile/profiler.py:646: error: Unused "type: ignore" comment  [unused-ignore]
+ src/pytest_autoprofile/profiler.py:688: error: Overloaded function signature 10 will never be matched: signature 3's parameter type(s) are the same or broader  [overload-cannot-match]
+ tests/test_patches.py:201: error: Unused "type: ignore" comment  [unused-ignore]

rotki (https://github.com/rotki/rotki)
+ rotkehlchen/exchanges/bitfinex.py:658: error: Unused "type: ignore" comment  [unused-ignore]
+ rotkehlchen/db/updates.py:218: error: Unused "type: ignore" comment  [unused-ignore]

beartype (https://github.com/beartype/beartype)
+ beartype/_util/cache/utilcacheobjattr.py:584: error: Unused "type: ignore" comment  [unused-ignore]
+ beartype/_util/api/standard/utilcontextlib.py:135: error: Unused "type: ignore" comment  [unused-ignore]

pytest (https://github.com/pytest-dev/pytest)
+ testing/test_warning_types.py:48: error: Unused "type: ignore" comment  [unused-ignore]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/arrays/string_.py:1051: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/arrays/arrow/array.py:3005: error: Unused "type: ignore" comment  [unused-ignore]

ibis (https://github.com/ibis-project/ibis)
- ibis/selectors.py:446: error: Item "function" of "Resolver | Callable[[Value], Value]" has no attribute "items"  [union-attr]
+ ibis/selectors.py:446: error: Item "FunctionType" of "Resolver | Callable[[Value], Value]" has no attribute "items"  [union-attr]

jax (https://github.com/google/jax)
- jax/_src/lax/parallel.py:3507: error: Cannot call function of unknown type  [operator]
- jax/_src/lax/parallel.py:3507: error: "function" not callable  [misc]
- jax/_src/lax/parallel.py:3507: error: Argument 1 to "partial" has incompatible type "function"; expected "Callable[..., Never]"  [arg-type]
- jax/_src/lax/parallel.py:3510: error: Cannot call function of unknown type  [operator]
- jax/_src/lax/parallel.py:3510: error: "function" not callable  [misc]
- jax/_src/lax/parallel.py:3510: error: Argument 1 to "partial" has incompatible type "function"; expected "Callable[..., Never]"  [arg-type]
- jax/_src/export/_export.py:851: note: "function" is missing following "Wrapped" protocol members:
+ jax/_src/export/_export.py:851: note: "FunctionType" is missing following "Wrapped" protocol members:
- jax/_src/pallas/triton/lowering.py:1435: error: Argument 1 to "lower_fun" has incompatible type "function"; expected "Callable[..., Any]"  [arg-type]
- jax/_src/pallas/mosaic/random.py:160: error: Argument 1 to "_make_stateful_sampler" has incompatible type overloaded function; expected "SampleFn"  [arg-type]
- jax/_src/pallas/mosaic/random.py:160: note: "SampleFn.__call__" has type "def __call__(self, key: Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex, *args: Any, shape: Sequence[int], **kwargs: Any) -> Array"
- jax/_src/pallas/mosaic/random.py:161: error: Argument 1 to "_make_stateful_sampler" has incompatible type "def uniform(key: Key | Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex, shape: Sequence[int] = ..., dtype: str | type[Any] | dtype[Any] | SupportsDType | None = ..., minval: Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex = ..., maxval: Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex = ..., *, out_sharding: NamedSharding | P | None = ...) -> Array"; expected "SampleFn"  [arg-type]
- jax/_src/pallas/mosaic/random.py:161: note: "SampleFn.__call__" has type "def __call__(self, key: Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex, *args: Any, shape: Sequence[int], **kwargs: Any) -> Array"
- jax/_src/pallas/mosaic/random.py:162: error: Argument 1 to "_make_stateful_sampler" has incompatible type "def bernoulli(key: Key | Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex, p: Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex = ..., shape: Sequence[int] | None = ..., mode: str = ..., *, out_sharding: NamedSharding | P | None = ...) -> Array"; expected "SampleFn"  [arg-type]
- jax/_src/pallas/mosaic/random.py:162: note: "SampleFn.__call__" has type "def __call__(self, key: Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex, *args: Any, shape: Sequence[int], **kwargs: Any) -> Array"
- jax/_src/pallas/mosaic/random.py:163: error: Argument 1 to "_make_stateful_sampler" has incompatible type "def normal(key: Key | Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex, shape: Sequence[int] = ..., dtype: str | type[Any] | dtype[Any] | SupportsDType | None = ..., *, mode: str | None = ..., out_sharding: NamedSharding | P | None = ...) -> Array"; expected "SampleFn"  [arg-type]
- jax/_src/pallas/mosaic/random.py:163: note: "SampleFn.__call__" has type "def __call__(self, key: Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex, *args: Any, shape: Sequence[int], **kwargs: Any) -> Array"
- jax/experimental/source_mapper/jaxpr.py:79: error: Argument "compile_fn" to "Pass" has incompatible type "def compile_jaxpr(work_dir: Any, f: Any, f_args: Any, f_kwargs: Any, **_: Any) -> Any"; expected "CompileFn"  [arg-type]
- jax/experimental/source_mapper/jaxpr.py:79: note: "CompileFn.__call__" has type "def __call__(self, Any, Any, Any, Any, /, **kwargs: Any) -> Any"
- jax/experimental/source_mapper/jaxpr.py:79: error: Argument "generate_dump" to "Pass" has incompatible type "def make_jaxpr_dump(jaxpr: Jaxpr, **_: Any) -> SourceMapDump"; expected "GenerateDumpFn"  [arg-type]
- jax/experimental/source_mapper/jaxpr.py:79: note: "GenerateDumpFn.__call__" has type "def __call__(self, Any, /, **kwargs: Any) -> SourceMapDump"
- jax/experimental/source_mapper/hlo.py:179: error: Argument "compile_fn" to "Pass" has incompatible type "def trace_and_lower(work_dir: Any, f: Any, f_args: Any, f_kwargs: Any, **_: Any) -> Any"; expected "CompileFn"  [arg-type]
- jax/experimental/source_mapper/hlo.py:179: note: "CompileFn.__call__" has type "def __call__(self, Any, Any, Any, Any, /, **kwargs: Any) -> Any"
- jax/experimental/source_mapper/hlo.py:180: error: Argument "generate_dump" to "Pass" has incompatible type "def stable_hlo_generate_dump(args: tuple[Any, str], **_: Any) -> SourceMapDump"; expected "GenerateDumpFn"  [arg-type]
- jax/experimental/source_mapper/hlo.py:180: note: "GenerateDumpFn.__call__" has type "def __call__(self, Any, /, **kwargs: Any) -> SourceMapDump"
- jax/experimental/source_mapper/hlo.py:201: error: Argument "compile_fn" to "Pass" has incompatible type "def trace_and_lower(work_dir: Any, f: Any, f_args: Any, f_kwargs: Any, **_: Any) -> Any"; expected "CompileFn"  [arg-type]
- jax/experimental/source_mapper/hlo.py:201: note: "CompileFn.__call__" has type "def __call__(self, Any, Any, Any, Any, /, **kwargs: Any) -> Any"
- jax/experimental/source_mapper/hlo.py:202: error: Argument "generate_dump" to "Pass" has incompatible type "def original_hlo_generate_dump(args: tuple[Any, str], **_: Any) -> SourceMapDump"; expected "GenerateDumpFn"  [arg-type]
- jax/experimental/source_mapper/hlo.py:202: note: "GenerateDumpFn.__call__" has type "def __call__(self, Any, /, **kwargs: Any) -> SourceMapDump"
- jax/experimental/source_mapper/hlo.py:224: error: Argument "compile_fn" to "Pass" has incompatible type "def trace_and_lower(work_dir: Any, f: Any, f_args: Any, f_kwargs: Any, **_: Any) -> Any"; expected "CompileFn"  [arg-type]
- jax/experimental/source_mapper/hlo.py:224: note: "CompileFn.__call__" has type "def __call__(self, Any, Any, Any, Any, /, **kwargs: Any) -> Any"
- jax/experimental/source_mapper/hlo.py:225: error: Argument "generate_dump" to "Pass" has incompatible type "def optimized_generate_dump(args: tuple[Any, str], xla_compiler_flags: dict[str, Any] | None = ..., **_: Any) -> SourceMapDump"; expected "GenerateDumpFn"  [arg-type]
- jax/experimental/source_mapper/hlo.py:225: note: "GenerateDumpFn.__call__" has type "def __call__(self, Any, /, **kwargs: Any) -> SourceMapDump"
- jax/_src/pallas/mosaic_gpu/pipeline.py:1222: note: "function" is missing following "WarpSpecializedPipeline" protocol member:
+ jax/_src/pallas/mosaic_gpu/pipeline.py:1222: note: "FunctionType" is missing following "WarpSpecializedPipeline" protocol member:

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/profiling/_asyncio.py:452: error: Unused "type: ignore" comment  [unused-ignore]
+ ddtrace/internal/utils/inspection.py:83: error: Redundant cast to "FunctionType"  [redundant-cast]
- ddtrace/contrib/internal/anyio/patch.py:66: error: Argument 1 to "wrap" has incompatible type "def [PosArgsT, T_Retval] run_sync(func: def (*args: *PosArgsT) -> T_Retval, *args: *PosArgsT, abandon_on_cancel: bool = ..., cancellable: bool | None = ..., limiter: CapacityLimiter | None = ...) -> Coroutine[Any, Any, T_Retval]"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/openfeature/_flagevaluation_writer.py:565: error: Non-overlapping container check (element type: "type[MethodType]", container item type: "type[timezone] | type[ZoneInfo]")  [comparison-overlap]
+ ddtrace/internal/symbol_db/symbols.py:534: error: Redundant cast to "FunctionType"  [redundant-cast]
+ ddtrace/contrib/internal/asyncio/_context_switch.py:50: error: Unused "type: ignore" comment  [unused-ignore]
+ ddtrace/contrib/internal/asyncio/_context_switch.py:52: error: Unused "type: ignore" comment  [unused-ignore]
+ ddtrace/contrib/internal/asyncio/_context_switch.py:57: error: Unused "type: ignore" comment  [unused-ignore]
- ddtrace/contrib/internal/asyncio/_context_switch.py:56: error: Argument 1 to "wrap" has incompatible type "def [_T_co] eager_task_factory(loop: AbstractEventLoop | None, coro: Coroutine[Any, Any, _T_co], *, name: str | None = ..., context: Context | None = ..., eager_start: bool = ...) -> Task[_T_co]"; expected "FunctionType"  [arg-type]
- ddtrace/contrib/internal/asyncio/_context_switch.py:56: note: Error code "arg-type" not covered by "type: ignore[attr-defined]" comment
+ ddtrace/debugging/_origin/span.py:192: error: Redundant cast to "FunctionType"  [redundant-cast]

graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/utilities/build_client_schema.py:278: error: Unused "type: ignore" comment  [unused-ignore]
+ src/graphql/utilities/build_client_schema.py:279: error: Unused "type: ignore" comment  [unused-ignore]
+ src/graphql/utilities/build_client_schema.py:280: error: Unused "type: ignore" comment  [unused-ignore]
+ src/graphql/utilities/build_client_schema.py:281: error: Unused "type: ignore" comment  [unused-ignore]
+ src/graphql/utilities/build_client_schema.py:282: error: Unused "type: ignore" comment  [unused-ignore]
+ src/graphql/utilities/build_client_schema.py:283: error: Unused "type: ignore" comment  [unused-ignore]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/directives/__init__.py: note: At top level:
+ sphinx/directives/__init__.py:338: error: Unused "type: ignore" comment  [unused-ignore]
- sphinx/util/docutils.py: note: In member "enable" of class "CustomReSTDispatcher":
- sphinx/util/docutils.py:280:31: error: Incompatible types in assignment (expression has type "Callable[[str, Module, document], tuple[type[Directive] | None, list[system_message]]]", variable has type "_DirectivesDispatcher")  [assignment]
- sphinx/util/docutils.py:280:31: note: "_DirectivesDispatcher.__call__" has type "Callable[[str, _LanguageModule, document], tuple[type[Directive] | None, list[system_message]]]"
- sphinx/util/docutils.py: note: At top level:
+ sphinx/util/docutils.py:307: error: Unused "type: ignore" comment  [unused-ignore]
+ sphinx/util/rst.py: note: At top level:
+ sphinx/util/rst.py:71: error: Unused "type: ignore" comment  [unused-ignore]

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ bson/__init__.py:962: error: Unused "type: ignore" comment  [unused-ignore]
+ bson/__init__.py:980: error: Unused "type: ignore" comment  [unused-ignore]
+ bson/__init__.py:1000: error: Unused "type: ignore" comment  [unused-ignore]

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/store_zip.py:463: error: Unused "type: ignore" comment  [unused-ignore]
+ static_frame/core/interface.py:923: error: Unused "type: ignore" comment  [unused-ignore]
+ static_frame/core/interface.py:958: error: Unused "type: ignore" comment  [unused-ignore]
+ static_frame/core/interface.py:988: error: Unused "type: ignore" comment  [unused-ignore]

starlette (https://github.com/encode/starlette)
+ starlette/routing.py:245: error: Cannot determine type of "methods"  [has-type]
+ starlette/routing.py:246: error: Cannot determine type of "methods"  [has-type]
+ starlette/routing.py:247: error: Cannot determine type of "methods"  [has-type]
+ starlette/routing.py:263: error: Cannot determine type of "methods"  [has-type]
+ starlette/routing.py:281: error: Cannot determine type of "methods"  [has-type]
+ starlette/routing.py:282: error: Cannot determine type of "methods"  [has-type]
+ starlette/routing.py:296: error: Cannot determine type of "methods"  [has-type]
+ starlette/routing.py:301: error: Cannot determine type of "methods"  [has-type]
+ starlette/schemas.py:80: error: Cannot determine type of "methods"  [has-type]
+ tests/test_applications.py:154: error: Unused "type: ignore" comment  [unused-ignore]

scipy-stubs (https://github.com/scipy/scipy-stubs)
+ tests/optimize/test_minimize.pyi:81: error: Expression is of type "OptimizeResult[Any] | Any", not "OptimizeResult[Any]"  [assert-type]
+ tests/optimize/test_minimize.pyi:82: error: Expression is of type "OptimizeResult[Any] | Any", not "OptimizeResult[Any]"  [assert-type]
+ tests/optimize/test_minimize_scalar.pyi:39: error: Expression is of type "OptimizeResult[Any] | Any", not "OptimizeResult[Any]"  [assert-type]
+ tests/optimize/test_minimize_scalar.pyi:40: error: Expression is of type "OptimizeResult[Any] | Any", not "OptimizeResult[Any]"  [assert-type]

@srittau

srittau commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

The primer output also looks great! Many errors, type ignores, and casts gone. I'm only confused about the starlette errors, which seem completely unrelated: https://github.com/Kludex/starlette/blob/63d868e1b89063fa1059dafe239e41f924c33805/starlette/routing.py#L245

@hamdanal
hamdanal marked this pull request as draft November 22, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't use builtins.function and others anymore

2 participants