python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.27k stars 2.79k forks source link

Propagate is_async_generator down to overloads #17435

Open sterliakov opened 3 months ago

sterliakov commented 3 months ago

Closes #17340

When an overloaded definition is checked, overloads usually have a trivial body. As a result, the return type of async overloads is wrapped with Coroutine, while the implementation is not - all this happens during semanal based solely on yield presence.

When such situation is encountered, we should unwrap the return type and mark the functions as async generators.

github-actions[bot] commented 3 months ago

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


steam.py (https://github.com/Gobot1234/steam.py)
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 1  [misc]
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 2  [misc]

jinja (https://github.com/pallets/jinja)
- src/jinja2/async_utils.py:70: error: Redundant cast to "V"  [redundant-cast]
- src/jinja2/environment.py:711: error: Unused "type: ignore" comment  [unused-ignore]
+ src/jinja2/filters.py:1499: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.11.0+dev.bfc9eefac0b65954875d59f1c14b643464876e11
+ src/jinja2/filters.py:1499: : note: use --pdb to drop into pdb
+ Traceback (most recent call last):
+   File "", line 8, in <module>
+     sys.exit(console_entry())
+   File "/__main__.py", line 15, in console_entry
+     main()
+   File "/main.py", line 103, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/main.py", line 187, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/build.py", line 193, in build
+     result = _build(
+   File "/build.py", line 268, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/build.py", line 2950, in dispatch
+     process_graph(graph, manager)
+   File "/build.py", line 3348, in process_graph
+     process_stale_scc(graph, scc, manager)
+   File "/build.py", line 3443, in process_stale_scc
+     mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
+   File "/semanal_main.py", line 94, in semantic_analysis_for_scc
+     process_functions(graph, scc, patches)
+   File "/semanal_main.py", line 252, in process_functions
+     process_top_level_function(
+   File "/semanal_main.py", line 291, in process_top_level_function
+     deferred, incomplete, progress = semantic_analyze_target(
+   File "/semanal_main.py", line 349, in semantic_analyze_target
+     analyzer.refresh_partial(
+   File "/semanal.py", line 622, in refresh_partial
+     self.accept(node)
+   File "/semanal.py", line 7105, in accept
+     node.accept(self)
+   File "/nodes.py", line 589, in accept
+     return visitor.visit_overloaded_func_def(self)
+   File "/semanal.py", line 1185, in visit_overloaded_func_def
+     self.analyze_overloaded_func_def(defn)
+   File "/semanal.py", line 1260, in analyze_overloaded_func_def
+     self.process_overload_impl(defn)
+   File "/semanal.py", line 1279, in process_overload_impl
+     self.propagate_async_generator_overloads(defn)
+   File "/semanal.py", line 1294, in propagate_async_generator_overloads
+     ret_type=fdef.func.type.ret_type.args[2]
+ IndexError: tuple index out of range

cloud-init (https://github.com/canonical/cloud-init)
+ /tmp/mypy_primer/projects/_cloud-init_venv/lib/python3.10/site-packages/jinja2/filters.py:1499: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.11.0+dev.bfc9eefac0b65954875d59f1c14b643464876e11
+ note: use --pdb to drop into pdb
- cloudinit/util.py:3250: error: Unused "type: ignore" comment  [unused-ignore]
- cloudinit/reporting/__init__.py:37: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/reporting/__init__.py:46: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/net/sysconfig.py:999: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/distros/package_management/apt.py:121: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/reporting/events.py:124: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/distros/__init__.py:165: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/distros/__init__.py:169: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/distros/debian.py:64: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/distros/alpine.py:278: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/sources/DataSourceOracle.py:143: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/sources/DataSourceAzure.py:1835: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/config/cc_ubuntu_pro.py:339: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/config/cc_ubuntu_pro.py:347: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/config/cc_growpart.py:298: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/config/cc_apt_configure.py:615: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/config/cc_apt_configure.py:616: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- tests/unittests/test_templating.py:268: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- tests/unittests/config/test_cc_ubuntu_drivers.py:84: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
- cloudinit/cmd/devel/hotplug_hook.py:83: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
+ Traceback (most recent call last):
+   File "", line 8, in <module>
+     sys.exit(console_entry())
+   File "/__main__.py", line 15, in console_entry
+     main()
+   File "/main.py", line 103, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/main.py", line 187, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/build.py", line 193, in build
+     result = _build(
+   File "/build.py", line 268, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/build.py", line 2950, in dispatch
+     process_graph(graph, manager)
+   File "/build.py", line 3348, in process_graph
+     process_stale_scc(graph, scc, manager)
+   File "/build.py", line 3443, in process_stale_scc
+     mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
+   File "/semanal_main.py", line 94, in semantic_analysis_for_scc
+     process_functions(graph, scc, patches)
+   File "/semanal_main.py", line 252, in process_functions
+     process_top_level_function(
+   File "/semanal_main.py", line 291, in process_top_level_function
+     deferred, incomplete, progress = semantic_analyze_target(
+   File "/semanal_main.py", line 349, in semantic_analyze_target
+     analyzer.refresh_partial(
+   File "/semanal.py", line 622, in refresh_partial
+     self.accept(node)
+   File "/semanal.py", line 7105, in accept
+     node.accept(self)
+   File "/nodes.py", line 589, in accept
+     return visitor.visit_overloaded_func_def(self)
+   File "/semanal.py", line 1185, in visit_overloaded_func_def
+     self.analyze_overloaded_func_def(defn)
+   File "/semanal.py", line 1260, in analyze_overloaded_func_def
+     self.process_overload_impl(defn)
+   File "/semanal.py", line 1279, in process_overload_impl
+     self.propagate_async_generator_overloads(defn)
+   File "/semanal.py", line 1294, in propagate_async_generator_overloads
+     ret_type=fdef.func.type.ret_type.args[2]
+ IndexError: tuple index out of range

nox (https://github.com/wntrblm/nox)
- Warning: unused section(s) in pyproject.toml: module = ['py']
+ /tmp/mypy_primer/projects/_nox_venv/lib/python3.10/site-packages/jinja2/filters.py:1499: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.11.0+dev.bfc9eefac0b65954875d59f1c14b643464876e11
+ note: use --pdb to drop into pdb
+ Traceback (most recent call last):
+   File "", line 8, in <module>
+     sys.exit(console_entry())
+   File "/__main__.py", line 15, in console_entry
+     main()
+   File "/main.py", line 103, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/main.py", line 187, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/build.py", line 193, in build
+     result = _build(
+   File "/build.py", line 268, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/build.py", line 2950, in dispatch
+     process_graph(graph, manager)
+   File "/build.py", line 3348, in process_graph
+     process_stale_scc(graph, scc, manager)
+   File "/build.py", line 3443, in process_stale_scc
+     mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
+   File "/semanal_main.py", line 94, in semantic_analysis_for_scc
+     process_functions(graph, scc, patches)
+   File "/semanal_main.py", line 252, in process_functions
+     process_top_level_function(
+   File "/semanal_main.py", line 291, in process_top_level_function
+     deferred, incomplete, progress = semantic_analyze_target(
+   File "/semanal_main.py", line 349, in semantic_analyze_target
+     analyzer.refresh_partial(
+   File "/semanal.py", line 622, in refresh_partial
+     self.accept(node)
+   File "/semanal.py", line 7105, in accept
+     node.accept(self)
+   File "/nodes.py", line 589, in accept
+     return visitor.visit_overloaded_func_def(self)
+   File "/semanal.py", line 1185, in visit_overloaded_func_def
+     self.analyze_overloaded_func_def(defn)
+   File "/semanal.py", line 1260, in analyze_overloaded_func_def
+     self.process_overload_impl(defn)
+   File "/semanal.py", line 1279, in process_overload_impl
+     self.propagate_async_generator_overloads(defn)
+   File "/semanal.py", line 1294, in propagate_async_generator_overloads
+     ret_type=fdef.func.type.ret_type.args[2]
+ IndexError: tuple index out of range

optuna (https://github.com/optuna/optuna)
+ /tmp/mypy_primer/projects/_optuna_venv/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/engine.py:516: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.11.0+dev.bfc9eefac0b65954875d59f1c14b643464876e11
+ note: use --pdb to drop into pdb
- optuna/samplers/_grid.py:126: error: Unused "type: ignore" comment  [unused-ignore]
- optuna/_gp/acqf.py:149: error: Unused "type: ignore" comment  [unused-ignore]
- optuna/_gp/acqf.py:150: error: Unused "type: ignore" comment  [unused-ignore]
- tests/gp_tests/test_acqf.py:59: error: Unused "type: ignore" comment  [unused-ignore]
- optuna/testing/storages.py:65: error: Unused "type: ignore" comment  [unused-ignore]
- optuna/importance/_ped_anova/scott_parzen_estimator.py:109: error: Unused "type: ignore" comment  [unused-ignore]
- optuna/importance/_ped_anova/scott_parzen_estimator.py:110: error: Unused "type: ignore" comment  [unused-ignore]
- tests/trial_tests/test_trial.py:613: error: Unused "type: ignore" comment  [unused-ignore]
- tests/storages_tests/journal_tests/test_journal.py:57: error: Unused "type: ignore" comment  [unused-ignore]
- tests/samplers_tests/test_nsgaii.py:968: error: Unused "type: ignore" comment  [unused-ignore]
- tests/samplers_tests/test_grid.py:43: error: Unused "type: ignore" comment  [unused-ignore]
- tests/samplers_tests/test_grid.py:51: error: Unused "type: ignore" comment  [unused-ignore]
- tests/samplers_tests/test_grid.py:57: error: Unused "type: ignore" comment  [unused-ignore]
- tests/samplers_tests/test_grid.py:69: error: Unused "type: ignore" comment  [unused-ignore]
- tests/samplers_tests/test_grid.py:123: error: Unused "type: ignore" comment  [unused-ignore]
- tests/artifacts_tests/test_boto3.py:17: error: Unused "type: ignore[attr-defined, no-redef]" comment  [unused-ignore]
+ Traceback (most recent call last):
+   File "", line 8, in <module>
+     sys.exit(console_entry())
+   File "/__main__.py", line 15, in console_entry
+     main()
+   File "/main.py", line 103, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/main.py", line 187, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/build.py", line 193, in build
+     result = _build(
+   File "/build.py", line 268, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/build.py", line 2950, in dispatch
+     process_graph(graph, manager)
+   File "/build.py", line 3348, in process_graph
+     process_stale_scc(graph, scc, manager)
+   File "/build.py", line 3443, in process_stale_scc
+     mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
+   File "/semanal_main.py", line 94, in semantic_analysis_for_scc
+     process_functions(graph, scc, patches)
+   File "/semanal_main.py", line 252, in process_functions
+     process_top_level_function(
+   File "/semanal_main.py", line 291, in process_top_level_function
+     deferred, incomplete, progress = semantic_analyze_target(
+   File "/semanal_main.py", line 349, in semantic_analyze_target
+     analyzer.refresh_partial(
+   File "/semanal.py", line 622, in refresh_partial
+     self.accept(node)
+   File "/semanal.py", line 7105, in accept
+     node.accept(self)
+   File "/nodes.py", line 589, in accept
+     return visitor.visit_overloaded_func_def(self)
+   File "/semanal.py", line 1185, in visit_overloaded_func_def
+     self.analyze_overloaded_func_def(defn)
+   File "/semanal.py", line 1260, in analyze_overloaded_func_def
+     self.process_overload_impl(defn)
+   File "/semanal.py", line 1279, in process_overload_impl
+     self.propagate_async_generator_overloads(defn)
+   File "/semanal.py", line 1294, in propagate_async_generator_overloads
+     ret_type=fdef.func.type.ret_type.args[2]
+ IndexError: tuple index out of range

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ /tmp/mypy_primer/projects/_pandas-stubs_venv/lib/python3.10/site-packages/jinja2/filters.py:1499: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.11.0+dev.bfc9eefac0b65954875d59f1c14b643464876e11
+ note: use --pdb to drop into pdb
- pandas-stubs/plotting/_core.pyi:343: error: Name "np.float_" is not defined  [name-defined]
- pandas-stubs/plotting/_core.pyi:357: error: Name "np.float_" is not defined  [name-defined]
- pandas-stubs/core/series.pyi:234: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:251: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:261: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:271: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:287: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:772: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:908: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1240: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1509: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1543: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1556: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1560: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1575: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1579: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1584: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1588: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1608: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/series.pyi:1992: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/resample.pyi:166: error: Name "np.float_" is not defined  [name-defined]
- pandas-stubs/core/frame.pyi:193: error: Overloaded function signatures 3 and 4 overlap with incompatible return types  [overload-overlap]
- pandas-stubs/core/frame.pyi:309: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/frame.pyi:325: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/frame.pyi:333: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/frame.pyi:341: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/frame.pyi:349: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/frame.pyi:1220: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/frame.pyi:1231: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/algorithms.pyi:27: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/algorithms.pyi:31: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/reshape/tile.pyi:53: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/reshape/tile.pyi:253: error: Name "np.float_" is not defined  [name-defined]
- pandas-stubs/core/reshape/tile.pyi:263: error: Name "np.float_" is not defined  [name-defined]
- pandas-stubs/core/reshape/tile.pyi:273: error: Name "np.float_" is not defined  [name-defined]
- pandas-stubs/core/reshape/concat.pyi:27: error: Overloaded function signatures 1 and 4 overlap with incompatible return types  [overload-overlap]
- pandas-stubs/core/reshape/concat.pyi:27: error: Overloaded function signatures 1 and 6 overlap with incompatible return types  [overload-overlap]
- pandas-stubs/core/indexes/interval.pyi:309: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:69: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:80: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:91: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:102: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:113: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:128: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:140: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:151: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:162: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:173: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:184: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:195: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:206: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:217: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/indexes/base.pyi:422: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/groupby/generic.pyi:188: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/groupby/generic.pyi:323: error: Unused "type: ignore" comment  [unused-ignore]
- pandas-stubs/core/arrays/timedeltas.pyi:45: error: Signature of "__mul__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:45: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:45: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:45: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:45: note:          def __mul__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:47: error: Signature of "__truediv__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:47: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:47: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:47: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:47: note:          def __truediv__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:48: error: Signature of "__rtruediv__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:48: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:48: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:48: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:48: note:          def __rtruediv__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:49: error: Signature of "__floordiv__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:49: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:49: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:49: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:49: note:          def __floordiv__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:50: error: Signature of "__rfloordiv__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:50: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:50: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:50: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:50: note:          def __rfloordiv__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:51: error: Signature of "__mod__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:51: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:51: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:51: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:51: note:          def __mod__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:52: error: Signature of "__rmod__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:52: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:52: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:52: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:52: note:          def __rmod__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:53: error: Signature of "__divmod__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:53: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:53: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:53: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:53: note:          def __divmod__(self, Any, /) -> Any
- pandas-stubs/core/arrays/timedeltas.pyi:54: error: Signature of "__rdivmod__" incompatible with supertype "DatetimeLikeArrayMixin"  [override]
- pandas-stubs/core/arrays/timedeltas.pyi:54: note:      Superclass:
- pandas-stubs/core/arrays/timedeltas.pyi:54: note:          EllipsisType
- pandas-stubs/core/arrays/timedeltas.pyi:54: note:      Subclass:
- pandas-stubs/core/arrays/timedeltas.pyi:54: note:          def __rdivmod__(self, other: Any) -> Any
- pandas-stubs/_libs/interval.pyi:204: error: Unused "type: ignore" comment  [unused-ignore]

... (truncated 58 lines) ...

typeshed-stats (https://github.com/AlexWaygood/typeshed-stats)
+ /tmp/mypy_primer/projects/_typeshed-stats_venv/lib/python3.10/site-packages/jinja2/filters.py:1499: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.11.0+dev.bfc9eefac0b65954875d59f1c14b643464876e11
+ note: use --pdb to drop into pdb
- src/typeshed_stats/_cli.py:80: error: Name "pprint" already defined on line 78  [no-redef]
- src/typeshed_stats/_cli.py:107: error: Unused "type: ignore" comment  [unused-ignore]
- src/typeshed_stats/_cli.py:115: error: Returning Any from function declared to return "type[HelpFormatter]"  [no-any-return]
- tests/test__cli.py:449: error: Returning Any from function declared to return "MagicMock"  [no-any-return]
+ Traceback (most recent call last):
+   File "", line 8, in <module>
+     sys.exit(console_entry())
+   File "/__main__.py", line 15, in console_entry
+     main()
+   File "/main.py", line 103, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/main.py", line 187, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/build.py", line 193, in build
+     result = _build(
+   File "/build.py", line 268, in _build
+     graph = dispatch(sources, manager, stdout)
+   File "/build.py", line 2950, in dispatch
+     process_graph(graph, manager)
+   File "/build.py", line 3348, in process_graph
+     process_stale_scc(graph, scc, manager)
+   File "/build.py", line 3443, in process_stale_scc
+     mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
+   File "/semanal_main.py", line 94, in semantic_analysis_for_scc
+     process_functions(graph, scc, patches)
+   File "/semanal_main.py", line 252, in process_functions
+     process_top_level_function(
+   File "/semanal_main.py", line 291, in process_top_level_function
+     deferred, incomplete, progress = semantic_analyze_target(
+   File "/semanal_main.py", line 349, in semantic_analyze_target
+     analyzer.refresh_partial(
+   File "/semanal.py", line 622, in refresh_partial
+     self.accept(node)
+   File "/semanal.py", line 7105, in accept
+     node.accept(self)
+   File "/nodes.py", line 589, in accept
+     return visitor.visit_overloaded_func_def(self)
+   File "/semanal.py", line 1185, in visit_overloaded_func_def
+     self.analyze_overloaded_func_def(defn)
+   File "/semanal.py", line 1260, in analyze_overloaded_func_def
+     self.process_overload_impl(defn)
+   File "/semanal.py", line 1279, in process_overload_impl
+     self.propagate_async_generator_overloads(defn)
+   File "/semanal.py", line 1294, in propagate_async_generator_overloads
+     ret_type=fdef.func.type.ret_type.args[2]
+ IndexError: tuple index out of range

speedrun.com_global_scoreboard_webapp (https://github.com/Avasam/speedrun.com_global_scoreboard_webapp)
+ /tmp/mypy_primer/projects/_speedrun.com_global_scoreboard_webapp_venv/lib/python3.10/site-packages/jinja2/filters.py:1499: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 1.11.0+dev.bfc9eefac0b65954875d59f1c14b643464876e11
+ note: use --pdb to drop into pdb
- backend/models/global_scoreboard_models.py:20: error: Need type annotation for "variables" (hint: "variables: dict[<type>, <type>] = ...")  [var-annotated]
- backend/models/tournament_scheduler_models.py:16: error: Variable "models.core_models.BaseModel" is not valid as a type  [valid-type]
- backend/models/tournament_scheduler_models.py:16: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- backend/models/tournament_scheduler_models.py:16: error: Invalid base class "BaseModel"  [misc]
- backend/models/tournament_scheduler_models.py:20: error: "Column" expects no type arguments, but 1 given  [type-arg]
- backend/models/tournament_scheduler_models.py:21: error: Cannot determine type of "db"  [has-type]
- backend/models/tournament_scheduler_models.py:23: error: "Column" expects no type arguments, but 1 given  [type-arg]
- backend/models/tournament_scheduler_models.py:23: error: Cannot determine type of "db"  [has-type]
- backend/models/tournament_scheduler_models.py:24: error: "Column" expects no type arguments, but 1 given  [type-arg]
- backend/models/tournament_scheduler_models.py:26: error: Cannot determine type of "db"  [has-type]

... (truncated 189 lines) ...```
github-actions[bot] commented 3 months ago

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

steam.py (https://github.com/Gobot1234/steam.py)
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 1  [misc]
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
sterliakov commented 3 months ago

Primer diff shows only one false positive removed. That error was caused exactly by mistreatment fixed in this PR.

hauntsaninja commented 3 months ago

Thanks for the PR! Since this changes the meanings of annotations, we should probably open a thread on https://discuss.python.org/c/typing/32 (e.g. pyright currently behaves the same as mypy)

sterliakov commented 3 months ago

This is being discussed at https://discuss.python.org/t/overloads-of-async-generators-inconsistent-coroutine-wrapping/56665.

sterliakov commented 3 months ago

I'm marking this draft for now, because Eric Traut seems to be against this idea, let's wait for some decision to settle.