microsoft / pyright

Static Type Checker for Python
Other
13.12k stars 1.4k forks source link

Fixed a bug that results in a false positive reportInconsistentOverlo… #8699

Closed erictraut closed 1 month ago

erictraut commented 1 month ago

…ad error when the implementation of the overload includes a decorator that changes the type of the implementation to a non-function type. This addresses #8692.

github-actions[bot] commented 1 month ago

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

anyio (https://github.com/agronholm/anyio)
- /tmp/mypy_primer/projects/anyio/src/anyio/abc/_eventloop.py
-   /tmp/mypy_primer/projects/anyio/src/anyio/abc/_eventloop.py:250:15 - error: Overloaded methods must all be abstract or not (reportInconsistentOverload)
-   /tmp/mypy_primer/projects/anyio/src/anyio/abc/_eventloop.py:316:15 - error: Overloaded methods must all be abstract or not (reportInconsistentOverload)
- 33 errors, 1 warning, 0 informations 
+ 31 errors, 1 warning, 0 informations 

steam.py (https://github.com/Gobot1234/steam.py)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/commands/commands.py:916:32 - error: Argument of type "Overload[(func: Context[Bot], /) -> MaybeBool@check, (func: MaybeCommandT@inner, /) -> MaybeCommandT@inner]" cannot be assigned to parameter "object" of type "Check[bool | Coro[bool]]" in function "append"
+     "function" is incompatible with protocol "Check[bool | Coro[bool]]"
+       "predicate" is not present
+       "__call__" is not present (reportArgumentType)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/commands/commands.py:926:15 - warning: Cannot assign to attribute "predicate" for class "function"
+     Attribute "predicate" is unknown (reportFunctionMemberAccess)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/commands/commands.py:933:15 - warning: Cannot assign to attribute "predicate" for class "function"
+     Attribute "predicate" is unknown (reportFunctionMemberAccess)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/commands/commands.py:935:12 - error: Expression of type "Overload[(func: Context[Bot], /) -> MaybeBool@check, (func: MaybeCommandT@inner, /) -> MaybeCommandT@inner]" is incompatible with return type "Check[MaybeBool@check]"
+     "function" is incompatible with protocol "Check[MaybeBool@check]"
+       "predicate" is not present
+       "__call__" is not present (reportReturnType)
- 8468 errors, 93 warnings, 0 informations 
+ 8470 errors, 95 warnings, 0 informations 

xarray (https://github.com/pydata/xarray)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:287:16 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:291:16 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:322:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:324:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:325:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:326:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:327:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:328:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:331:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:334:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:337:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:343:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:346:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:350:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:353:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:367:19 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:371:19 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:375:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:386:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:410:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:411:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:433:17 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:449:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:450:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:465:14 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:503:14 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:787:31 - error: Argument of type "Literal['ro']" cannot be assigned to parameter "self" of type "DataArrayPlotAccessor" in function "__call__"
-     "Literal['ro']" is incompatible with "DataArrayPlotAccessor" (reportArgumentType)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:794:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:797:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:803:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:810:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:818:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:826:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:833:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:844:15 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:849:15 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:853:15 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:858:15 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:873:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:881:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:889:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:901:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1255:21 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1262:21 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1679:14 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1796:18 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1807:18 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1901:18 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1950:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1955:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1961:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1964:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1984:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1990:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:1996:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2003:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2010:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2012:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2013:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2018:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2023:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2040:15 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2049:17 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2052:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2058:15 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2070:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2075:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2080:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2248:30 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2347:13 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2416:9 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/xarray/xarray/tests/test_plot.py:2419:9 - error: Argument missing for parameter "self" (reportCallIssue)

... (truncated 59 lines) ...

mkdocs (https://github.com/mkdocs/mkdocs)
+   /tmp/mypy_primer/projects/mkdocs/mkdocs/config/config_options.py:954:28 - error: Expected 1 more positional argument (reportCallIssue)
-   /tmp/mypy_primer/projects/mkdocs/mkdocs/config/config_options.py:954:28 - error: No overloads for "__init__" match the provided arguments
-     Argument types: () (reportCallIssue)
+   /tmp/mypy_primer/projects/mkdocs/mkdocs/config/defaults.py:199:18 - error: Expected 1 more positional argument (reportCallIssue)
-   /tmp/mypy_primer/projects/mkdocs/mkdocs/config/defaults.py:199:18 - error: No overloads for "__init__" match the provided arguments
-     Argument types: () (reportCallIssue)
-   /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_tests.py:1594:22 - error: No overloads for "__init__" match the provided arguments
+   /tmp/mypy_primer/projects/mkdocs/mkdocs/tests/config/config_options_tests.py:1594:22 - error: Expected 1 more positional argument (reportCallIssue)
-     Argument types: () (reportCallIssue)

jax (https://github.com/google/jax)
-   /tmp/mypy_primer/projects/jax/jax/_src/numpy/lax_numpy.py:3229:22 - error: Cannot access attribute "ndim" for class "list[Array]"
-     Attribute "ndim" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/jax/jax/_src/numpy/linalg.py:954:41 - error: Cannot access attribute "astype" for class "tuple[Array, ...]"
-   /tmp/mypy_primer/projects/jax/jax/_src/numpy/linalg.py:1382:36 - error: Cannot access attribute "astype" for class "tuple[Array, ...]"
- 6122 errors, 26 warnings, 0 informations 
+ 6121 errors, 26 warnings, 0 informations