Message385350
Another example: the unimport project ("linter, formatter for finding and removing unused import statements") uses the following function to guess if a module object is part of the stdlib:
def is_std(package: str) -> bool:
"""Returns True if package module came with from Python."""
if package in C.BUILTIN_MODULE_NAMES:
return True
spec = get_spec(package)
if spec and isinstance(spec.origin, str):
return any(
(
spec.origin.startswith(C.STDLIB_PATH),
spec.origin in ["built-in", "frozen"],
spec.origin.endswith(".so"),
)
)
else:
return False
https://github.com/hakancelik96/unimport/blob/c9bd5de99bd8a5239d3dee2c3ff633979bb3ead2/unimport/utils.py#L61-L77 |
|
Date |
User |
Action |
Args |
2021-01-20 16:00:32 | vstinner | set | recipients:
+ vstinner, ronaldoussoren, serhiy.storchaka, corona10 |
2021-01-20 16:00:32 | vstinner | set | messageid: <1611158432.73.0.677251837635.issue42955@roundup.psfhosted.org> |
2021-01-20 16:00:32 | vstinner | link | issue42955 messages |
2021-01-20 16:00:32 | vstinner | create | |
|