reportMissingTypeArgument.md
April 8, 2026 · View on GitHub
Overview
reportMissingTypeArgument is a diagnostic in Pylance and Pyright that warns when a generic type is used without specifying the required type arguments. This helps catch ambiguous or incomplete type usage, improving code reliability and maintainability.
Representative Issues
- #2253: Ensure that type arguments are provided when defining generic type aliases to avoid ambiguous typing errors.
- #5267: Ensure that generics are properly utilized in class hierarchies by specifying type arguments, especially when dealing with inheritance.
- #966: Ensure that generic type aliases are properly instantiated with the correct type arguments to avoid confusion in variable types.
Examples
from typing import Generic, TypeVar
_T = TypeVar("_T")
class Box(Generic[_T]):
def __init__(self, item: _T):
self.item = item
# Warning: Missing type argument for "Box"
class SpecialBox(Box): # Should be Box[int], Box[str], etc.
pass
# Warning: Missing type argument for "Box"
var: Box | None = None
Fix — provide the type argument:
class SpecialBox(Box[int]):
pass
var: Box[str] | None = None
Common Fixes & Workarounds
- Always provide the required type arguments when using generic types or type aliases.
- Refactor code to specify type arguments for all generics and type aliases.
- Use type stubs or install third-party stubs for external libraries if needed.
- Review the Pyright configuration documentation for options to adjust or suppress this diagnostic if needed.
See Also
python.analysis.diagnosticSeverityOverrides— adjust or suppress this diagnosticpython.analysis.typeCheckingMode— controls which diagnostics are enabled by default