You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
591 B
22 lines
591 B
# mypy: allow-untyped-defs
|
|
"""List of Python standard library modules.
|
|
|
|
Sadly, there is no reliable way to tell whether a module is part of the
|
|
standard library except by comparing to a canonical list.
|
|
|
|
This is taken from https://github.com/PyCQA/isort/tree/develop/isort/stdlibs,
|
|
which itself is sourced from the Python documentation.
|
|
"""
|
|
|
|
import sys
|
|
|
|
|
|
def is_stdlib_module(module: str) -> bool:
|
|
base_module = module.partition(".")[0]
|
|
return base_module in _get_stdlib_modules()
|
|
|
|
|
|
def _get_stdlib_modules():
|
|
assert sys.version_info >= (3, 10)
|
|
return sys.stdlib_module_names
|