reportUnsupportedDunderAll.md

April 8, 2026 · View on GitHub

Overview

reportUnsupportedDunderAll is a Pylance diagnostic that warns when your code uses the __all__ symbol in ways that are not supported by static type checkers. This helps you avoid patterns that may work at runtime but are not recognized by tools like Pylance and Pyright, ensuring your module exports are clear and type-safe.

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.
  • #4286: Ensure that Protocol classes are consistently imported from the typing_extensions module to avoid runtime issues with static type checkers.

Examples

Error:

my_string = "helper"

__all__ = ["main_func", my_string]  # Non-literal string in __all__

def main_func(): ...
def helper(): ...

Fix — use only string literals:

__all__ = ["main_func", "helper"]  # All entries are string literals

def main_func(): ...
def helper(): ...

Another unsupported pattern:

__all__ = ["a"]
__all__ += ["b"]  # Augmented assignment not supported by type checkers

Fix by assigning the full list at once:

__all__ = ["a", "b"]

Common Fixes & Workarounds

  1. Use only simple, static lists of string names for __all__ (e.g., __all__ = ["foo", "bar"]).
  2. Avoid dynamically constructing or modifying __all__ at runtime.
  3. If you need dynamic exports, consider using explicit imports and exports instead.
  4. Refer to the Pyright configuration documentation to adjust the severity or disable this diagnostic if needed.

See Also