Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reportUnusedFunction on unused protected methods when the class is decorated with @final #937

Merged
merged 2 commits into from
Dec 8, 2024

Conversation

DetachHead
Copy link
Owner

fixes #548

@DetachHead DetachHead force-pushed the reportUnusedFunction-final branch from 741d770 to 9bbaec9 Compare December 8, 2024 07:21

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Dec 8, 2024

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

pytest (https://github.com/pytest-dev/pytest)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/fixtures.py:690:9 - warning: Function "_fillfixtures" is not accessed (reportUnusedFunction)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/main.py:644:9 - warning: Function "_node_location_to_relpath" is not accessed (reportUnusedFunction)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/_io/terminalwriter.py:186:9 - warning: Function "_write_source" is not accessed (reportUnusedFunction)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/config/__init__.py:1112:9 - warning: Function "_do_configure" is not accessed (reportUnusedFunction)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/config/__init__.py:1666:9 - warning: Function "_getconftest_pathlist" is not accessed (reportUnusedFunction)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/config/__init__.py:1792:9 - warning: Function "_add_verbosity_ini" is not accessed (reportUnusedFunction)
- 1159 errors, 17274 warnings, 0 notes
+ 1159 errors, 17280 warnings, 0 notes

sympy (https://github.com/sympy/sympy)
-     Type of "i" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "i" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "rootof" is "(f: Unknown, x: Unknown, index: Unknown | None = None, radicals: bool = True, expand: bool = True) -> (Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Expr)" (reportUnknownVariableType)
+     Type of "rootof" is "(f: Unknown, x: Unknown, index: Unknown | None = None, radicals: bool = True, expand: bool = True) -> (Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType | Expr)" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:134:9 - warning: Type of "inf" is partially unknown
-     Type of "inf" is "One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown" (reportUnknownVariableType)
-     Argument type is "Equality | Unknown | Relational | Unequality" (reportUnknownArgumentType)
+     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
-     Argument type is "Equality | Unknown | Relational | Unequality" (reportUnknownArgumentType)
+     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
-     Type of "e" is "Equality | Unknown | Relational | Unequality | NaN | Sum" (reportUnknownVariableType)
+     Type of "e" is "Equality | Unknown | NaN | Sum" (reportUnknownVariableType)
-     Argument type is "Equality | Unknown | Relational | Unequality" (reportUnknownArgumentType)
+     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
-     Argument type is "Equality | Unknown | Relational | Unequality" (reportUnknownArgumentType)
+     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
-     Argument type is "Equality | Unknown | Relational | Unequality" (reportUnknownArgumentType)
+     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
-     Argument type is "Equality | Unknown | Relational | Unequality" (reportUnknownArgumentType)
+     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
-     Type of "r" is "Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Expr" (reportUnknownVariableType)
+     Type of "r" is "Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType | Expr" (reportUnknownVariableType)
-     Type of "ie" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "ie" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "e" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "e" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "wave" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "wave" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "sol4" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "sol4" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "expand" is "((**kwargs: Unknown) -> Equality) | Unknown | ((**kwargs: Unknown) -> Relational) | ((**kwargs: Unknown) -> Unequality)" (reportUnknownMemberType)
+     Type of "expand" is "((**kwargs: Unknown) -> Equality) | Unknown" (reportUnknownMemberType)
-     Type of "expand" is "((**kwargs: Unknown) -> Equality) | Unknown | ((**kwargs: Unknown) -> Relational) | ((**kwargs: Unknown) -> Unequality)" (reportUnknownMemberType)
+     Type of "expand" is "((**kwargs: Unknown) -> Equality) | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_recurr.py:116:5 - warning: Type of "h" is unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_recurr.py:116:5 - warning: Type of "h" is Any (reportAny)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:104:9 - warning: Return type, "tuple[int, list[_NotImplementedType | Unknown | Any | GreaterThan | Equality | Relational | Unequality], Any]", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:104:9 - warning: Return type, "tuple[int, list[_NotImplementedType | Unknown | Any | GreaterThan | Equality | Relational | Unequality | LessThan | bool], Any]", is partially unknown (reportUnknownParameterType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:105:13 - warning: Return type, "Integer | Unknown | NaN | Expr | One | NegativeOne | Zero | Rational | ComplexInfinity | Half", is partially unknown (reportUnknownParameterType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:109:20 - warning: Return type, "Unknown | NaN | Expr | One | NegativeOne | Zero | Integer | Rational | ComplexInfinity | Half", is partially unknown (reportUnknownVariableType)
-     Type of "constraints" is "list[_NotImplementedType | Unknown | Any | GreaterThan | Equality | Relational | Unequality]" (reportUnknownVariableType)
+     Type of "constraints" is "list[_NotImplementedType | Unknown | Any | GreaterThan | Equality | Relational | Unequality | LessThan | bool]" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:111:29 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "iterable" in function "sum"
-     Argument type is "Generator[Any | Unknown, None, None]" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:113:25 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "iterable" in function "sum"
-     Argument type is "Generator[Any | Unknown, None, None]" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:114:16 - warning: Return type, "tuple[int, list[_NotImplementedType | Unknown | Any | GreaterThan | Equality | Relational | Unequality], Any]", is partially unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:114:16 - warning: Return type, "tuple[int, list[_NotImplementedType | Unknown | Any | GreaterThan | Equality | Relational | Unequality | LessThan | bool], Any]", is partially unknown (reportUnknownVariableType)
-     Type of "r1" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "r1" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "r2" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "r2" is "Equality | Unknown" (reportUnknownVariableType)
-     Type of "constraints" is "list[Equality | Unknown | Relational | Unequality | Any]" (reportUnknownVariableType)
+     Type of "constraints" is "list[Equality | Unknown | Any]" (reportUnknownVariableType)
-     Type of "constr" is "Equality | Unknown | Relational | Unequality | Any" (reportUnknownVariableType)
+     Type of "constr" is "Equality | Unknown | Any" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:181:5 - warning: Type of "ans" is partially unknown
-     Type of "ans" is "tuple[Unknown, list[int | Unknown]]" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:221:9 - warning: Type of "ans" is partially unknown
-     Type of "ans" is "tuple[Unknown, list[int | Unknown]]" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:222:48 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "iterable" in function "__init__"
-     Argument type is "zip[tuple[Any, int | Unknown]]" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:222:55 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "iter2" in function "__new__"
-     Argument type is "list[int | Unknown]" (reportUnknownArgumentType)
-     Type of "eq" is "list[Equality | Unknown | Relational | Unequality]" (reportUnknownVariableType)
+     Type of "eq" is "list[Equality | Unknown]" (reportUnknownVariableType)
-     Type of "i" is "Equality | Unknown | Relational | Unequality" (reportUnknownVariableType)
+     Type of "i" is "Equality | Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:229:9 - warning: Type of "ans" is partially unknown
-     Type of "ans" is "tuple[Unknown, list[int | Unknown]]" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_simplex.py:230:53 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "iterable" in function "__init__"
-     Argument type is "zip[tuple[Any, int | Unknown]]" (reportUnknownArgumentType)

... (truncated 4857 lines) ...

trio (https://github.com/python-trio/trio)
+   /tmp/mypy_primer/projects/trio/src/trio/_util.py:326:9 - error: Function "_create" is not accessed (reportUnusedFunction)
+   /tmp/mypy_primer/projects/trio/src/trio/_core/_mock_clock.py:126:9 - error: Function "_autojump" is not accessed (reportUnusedFunction)
- 4168 errors, 55 warnings, 0 notes
+ 4170 errors, 55 warnings, 0 notes

aiohttp (https://github.com/aio-libs/aiohttp)
+   /tmp/mypy_primer/projects/aiohttp/aiohttp/web_app.py:222:9 - warning: Function "_set_loop" is not accessed (reportUnusedFunction)
+   /tmp/mypy_primer/projects/aiohttp/aiohttp/web_app.py:387:15 - warning: Function "_handle" is not accessed (reportUnusedFunction)
- 320 errors, 5705 warnings, 0 notes
+ 320 errors, 5707 warnings, 0 notes

spack (https://github.com/spack/spack)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-t/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-t/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-t/package.py:18:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-t/package.py:18:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vh/package.py:21:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vh/package.py:21:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vh/package.py:22:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vh/package.py:22:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vt/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vt/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vt/package.py:18:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/splice-vt/package.py:18:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/sticky-variant-dependent/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/sticky-variant-dependent/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/transitive-conditional-virtual-dependency/package.py:14:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/transitive-conditional-virtual-dependency/package.py:14:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/trigger-external-non-default-variant/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/trigger-external-non-default-variant/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/unsat-virtual-dependency/package.py:16:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/unsat-virtual-dependency/package.py:16:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/v1-consumer/package.py:17:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/v1-consumer/package.py:17:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/v1-consumer/package.py:18:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/v1-consumer/package.py:18:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-root/package.py:21:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-root/package.py:21:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-root/package.py:22:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/variant-on-dependency-condition-root/package.py:22:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/vdefault-or-external/package.py:20:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/vdefault-or-external/package.py:20:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/vdefault-or-external-root/package.py:18:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/vdefault-or-external-root/package.py:18:5 - warning: Result of call expression is of type "((pkg: type[PackageBase]) -> None)" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/spack/var/spack/repos/builtin.mock/packages/version-test-pkg/package.py:24:5 - warning: Result of call expression is of type "(pkg: type[PackageBase]) -> None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)

... (truncated 153 lines) ...

@DetachHead DetachHead merged commit 2fd23b1 into main Dec 8, 2024
20 checks passed
@DetachHead DetachHead deleted the reportUnusedFunction-final branch December 8, 2024 11:47
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.

reportUnusedFunction false negative on protected methods of @final classes
1 participant