From 4f50553a8056ce5c57effac0641f442c62708a5b Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Fri, 16 Aug 2024 19:55:00 +0530 Subject: [PATCH] Document the latest code change a bit better. --- src/pytest_beartype/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pytest_beartype/__init__.py b/src/pytest_beartype/__init__.py index 1d14e55..c5a3467 100644 --- a/src/pytest_beartype/__init__.py +++ b/src/pytest_beartype/__init__.py @@ -39,8 +39,6 @@ def pytest_configure(config: "pytest.Config") -> None: import sys from warnings import warn - stdlib_module_names = getattr(sys, "stdlib_module_names", []) - class BeartypePytestWarning(BeartypeWarning): """ Beartype :mod:`pytest` warning. @@ -50,6 +48,12 @@ class BeartypePytestWarning(BeartypeWarning): under the active Python interpreter. """ + # This (and `sys.builtin_module_names`) will be used to filter out + # already-imported modules from the warning message (about the fact that + # some modules have already been imported and will not be checked), whenever + # `--beartype-packages=*` or `--beartype-skip-packages` flags are used. + stdlib_module_names = getattr(sys, "stdlib_module_names", []) + # Tuple of the subset of these names corresponding to previously # imported packages and modules under the active Python interpreter. if "*" in package_names: