MCPcopy Index your code
hub / github.com/python/mypy / is_non_library_module

Function is_non_library_module

mypy/stubgen.py:1640–1667  ·  view source on GitHub ↗

Does module look like a test module or a script?

(module: str)

Source from the content-addressed store, hash-verified

1638
1639
1640def is_non_library_module(module: str) -> bool:
1641 """Does module look like a test module or a script?"""
1642 if module.endswith(
1643 (
1644 ".tests",
1645 ".test",
1646 ".testing",
1647 "_tests",
1648 "_test_suite",
1649 "test_util",
1650 "test_utils",
1651 "test_base",
1652 ".__main__",
1653 ".conftest", # Used by pytest
1654 ".setup", # Typically an install script
1655 )
1656 ):
1657 return True
1658 if module.split(".")[-1].startswith("test_"):
1659 return True
1660 if (
1661 ".tests." in module
1662 or ".test." in module
1663 or ".testing." in module
1664 or ".SelfTest." in module
1665 ):
1666 return True
1667 return False
1668
1669
1670def translate_module_name(module: str, relative: int) -> tuple[str, int]:

Calls 3

splitMethod · 0.80
endswithMethod · 0.45
startswithMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…