def get_typeshed_stdlib_modules(custom_typeshed_dir: Optional[str]) -> List[str]:
    'Returns a list of stdlib modules in typeshed (for current Python version).'
    stdlib_py_versions = mypy.modulefinder.load_stdlib_py_versions(custom_typeshed_dir)
    packages = set()
    if (sys.version_info < (3, 6)):
        version_info = (3, 6)
    else:
        version_info = sys.version_info[0:2]
    for (module, versions) in stdlib_py_versions.items():
        (minver, maxver) = versions
        if ((version_info >= minver) and ((maxver is None) or (version_info <= maxver))):
            packages.add(module)
    if custom_typeshed_dir:
        typeshed_dir = Path(custom_typeshed_dir)
    else:
        typeshed_dir = (Path(mypy.build.default_data_dir()) / 'typeshed')
    stdlib_dir = (typeshed_dir / 'stdlib')
    modules = []
    for path in stdlib_dir.rglob('*.pyi'):
        if (path.stem == '__init__'):
            path = path.parent
        module = '.'.join((path.relative_to(stdlib_dir).parts[:(- 1)] + (path.stem,)))
        if (module.split('.')[0] in packages):
            modules.append(module)
    return sorted(modules)
Returns a list of stdlib modules in typeshed (for current Python version).
def get_typeshed_stdlib_modules(custom_typeshed_dir: Optional[str]) -> List[str]:
    
    stdlib_py_versions = mypy.modulefinder.load_stdlib_py_versions(custom_typeshed_dir)
    packages = set()
    if (sys.version_info < (3, 6)):
        version_info = (3, 6)
    else:
        version_info = sys.version_info[0:2]
    for (module, versions) in stdlib_py_versions.items():
        (minver, maxver) = versions
        if ((version_info >= minver) and ((maxver is None) or (version_info <= maxver))):
            packages.add(module)
    if custom_typeshed_dir:
        typeshed_dir = Path(custom_typeshed_dir)
    else:
        typeshed_dir = (Path(mypy.build.default_data_dir()) / 'typeshed')
    stdlib_dir = (typeshed_dir / 'stdlib')
    modules = []
    for path in stdlib_dir.rglob('*.pyi'):
        if (path.stem == '__init__'):
            path = path.parent
        module = '.'.join((path.relative_to(stdlib_dir).parts[:(- 1)] + (path.stem,)))
        if (module.split('.')[0] in packages):
            modules.append(module)
    return sorted(modules)