reportUnusedCallResult.md
April 8, 2026 · View on GitHub
Overview
reportUnusedCallResult is a Pylance and Pyright diagnostic that warns when the result of a function or method call is not used. This can help identify places where you may have forgotten to use or store a value, or where code can be simplified.
Representative Issues
- #3102: Ensure that default argument types in functions match the annotated parameter types to avoid runtime errors and type checking issues.
- #4163: Ensure consistency in the use of type stubs between Pyright's CLI and Pylance settings, especially with
useLibraryCodeForTypes. - #5200: Provide a configuration setting to allow users to customize diagnostic rule severities based on the type checking mode, improving the granularity of error reporting.
- #7001: Prefer 'openFilesOnly' diagnostic mode for large projects to avoid full reanalysis on every edit; use workspace analysis selectively.
- #1125: Consider using explicit statements to indicate that a returned value is intentionally ignored to mitigate false positives from unused call results.
- #1320: Document the interaction between
typeCheckingModeand specific diagnostic settings to clarify their effects on each other. - #4367: Ensure that comments in TOML files use the correct line endings and do not contain unsupported control characters to avoid parse errors.
- #6756: Avoid using throwaway variables
_when the result's type is unknown, as it can trigger strict type checks that expect assigned variables to have known types. - #7192: Avoid redeclaring variables with the same type to prevent shadowing and ensure clear variable identification.
- #7193: After an
isinstancecheck with a specific type, the variable should be explicitly set to that type or a more specific type to avoid false positive errors in static analysis tools.
Examples
Error:
def get_config() -> dict[str, str]:
return {"mode": "fast"}
get_config() # Return value is not used
Fix — capture or explicitly discard the result:
config = get_config() # Use the return value
If the side effect is intentional and the return value should be ignored:
_ = get_config() # Explicitly discard
Common Fixes & Workarounds
- Assign the result of a function call to a variable if you intend to use it later.
- If the result is intentionally unused, consider using a comment or a clearly named variable (e.g.,
_unused) to indicate this. - Review your code for places where a function call's result should be used or returned.
- Adjust your Pyright or Pylance configuration if you want to change the severity or disable this diagnostic. See the Pyright configuration documentation for details.
See Also
python.analysis.diagnosticSeverityOverrides— adjust or suppress this diagnosticpython.analysis.typeCheckingMode— controls which diagnostics are enabled by default