reportUnknownMemberType.md
April 8, 2026 · View on GitHub
Overview
reportUnknownMemberType is a diagnostic in Pylance and Pyright that warns when the type of a class or object member cannot be determined. This helps catch missing or ambiguous type information for members, improving static analysis and code safety.
Representative Issues
- #1449: Ensure that the configuration file specified in a project is correctly referenced and applied by the development environment.
- #1455: Exclude third-party package directories like pypackages from analysis and configure paths explicitly in pyproject.toml for accurate type checking.
- #1997: Implement more specific analysis rules or allow for different severity levels to be configured for
reportUnknownMemberType. - #2071: Ensure that type stubs are correctly imported using the
X as Xform. - #3084: Ensure that the library you are using includes a "py.typed" file to provide accurate type information for Pylance.
Examples
Error:
class Config:
def __init__(self):
self.timeout = get_default() # get_default returns Any → member type unknown
Fix — add a type annotation to the member:
class Config:
timeout: int
def __init__(self):
self.timeout = get_default()
Or annotate in __init__:
class Config:
def __init__(self):
self.timeout: int = get_default()
Common Fixes & Workarounds
- Add explicit type annotations to class and object members where possible.
- Use or install type stubs for third-party libraries.
- Refactor code to clarify member types where 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