This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients corona10, ronaldoussoren, serhiy.storchaka, vstinner
Date 2021-01-20.16:00:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611158432.73.0.677251837635.issue42955@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-01-20 16:00:32vstinnersetrecipients: + vstinner, ronaldoussoren, serhiy.storchaka, corona10
2021-01-20 16:00:32vstinnersetmessageid: <1611158432.73.0.677251837635.issue42955@roundup.psfhosted.org>
2021-01-20 16:00:32vstinnerlinkissue42955 messages
2021-01-20 16:00:32vstinnercreate