Repository: beartype/pytest-beartype (language: python)

Issue:
[Feature Request] Beartype all the things
If I put `*` I would like to run beartype on all packages


Discussion / hints:
You know what, great idea. I'll have to dig a little bit into beartype for this but it is an important feature to have.

Fix patch:
diff --git a/setup.cfg b/setup.cfg
index 026c1b8..cea0c4e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = pytest-beartype
-version = 0.0.2
+version = 0.1.0
 description = Pytest plugin to run your tests with beartype checking enabled.
 long_description = file: README.md
 long_description_content_type = text/markdown


Test patch:
diff --git a/src/pytest_beartype/__init__.py b/src/pytest_beartype/__init__.py
index a0ac734..1d14e55 100644
--- a/src/pytest_beartype/__init__.py
+++ b/src/pytest_beartype/__init__.py
@@ -1,4 +1,5 @@
 """pytest-beartype - Pytest plugin to run your tests with beartype checking enabled."""
+
 from __future__ import annotations
 
 import pytest
@@ -33,11 +34,13 @@ def pytest_configure(config: "pytest.Config") -> None:
         # avoid performing *ANY* imports unless the user actually passed the
         # "--beartype-packages" option declared by this plugin.
         from beartype.roar import BeartypeWarning
-        from beartype.claw import beartype_packages
+        from beartype.claw import beartype_all, beartype_packages
         from beartype._util.text.utiltextjoin import join_delimited
-        from sys import modules
+        import sys
         from warnings import warn
 
+        stdlib_module_names = getattr(sys, "stdlib_module_names", [])
+
         class BeartypePytestWarning(BeartypeWarning):
             """
             Beartype :mod:`pytest` warning.
@@ -49,9 +52,35 @@ class BeartypePytestWarning(BeartypeWarning):
 
         # Tuple of the subset of these names corresponding to previously
         # imported packages and modules under the active Python interpreter.
-        package_imported_names = tuple(
-            package_name for package_name in package_names if package_name in modules
-        )
+        if "*" in package_names:
+            imported_packages = sorted(
+                {module.partition(".")[0] for module in sys.modules}
+            )
+            beartype_imported_packages = (
+                "__main__",
+                "beartype",
+                "_pytest",
+                "iniconfig",
+                "pluggy",
+                "py",
+                "pytest",
+                "pytest_beartype",
+            )
+            package_imported_names = tuple(
+                package
+                for package in imported_packages
+                if (
+                    package not in beartype_imported_packages
+                    and package not in sys.builtin_module_names
+                    and package not in stdlib_module_names
+                )
+            )
+        else:
+            package_imported_names = tuple(
+                package_name
+                for package_name in package_names
+                if package_name in sys.modules
+            )
 
         # If at least one of these packages or modules has already been
         # imported...
@@ -76,4 +105,7 @@ class BeartypePytestWarning(BeartypeWarning):
             )
 
         # Install an import hook type-checking these packages and modules.
-        beartype_packages(package_names)
+        if "*" in package_names:
+            beartype_all()
+        else:
+            beartype_packages(package_names)