pw_presubmit: Simplify adding only pylint and mypy

Simplify adding only the pylint and mypy checks to downstream projects
and not adding test_python_packages.

Change-Id: Ib94f19dec61ea90937eb35445e4ea341697f5601
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/55982
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_presubmit/docs.rst b/pw_presubmit/docs.rst
index 58fc42e..cd4ca6b 100644
--- a/pw_presubmit/docs.rst
+++ b/pw_presubmit/docs.rst
@@ -233,12 +233,15 @@
       format_code.presubmit_checks(exclude=PATH_EXCLUSIONS),
       # Include the upstream inclusive language check.
       inclusive_language.inclusive_language,
+      # Include just the lint-related Python checks.
+      python_checks.lint_checks(exclude=PATH_EXCLUSIONS),
   )
 
   FULL = (
       QUICK,  # Add all checks from the 'quick' program
       release_build,
       # Use the upstream Python checks, with custom path filters applied.
+      # Checks listed multiple times are only run once.
       python_checks.all_checks(exclude=PATH_EXCLUSIONS),
   )
 
diff --git a/pw_presubmit/py/pw_presubmit/python_checks.py b/pw_presubmit/py/pw_presubmit/python_checks.py
index 1f1e0cd..0f693e8 100644
--- a/pw_presubmit/py/pw_presubmit/python_checks.py
+++ b/pw_presubmit/py/pw_presubmit/python_checks.py
@@ -137,12 +137,23 @@
             env=env)
 
 
-_ALL_CHECKS = (
-    test_python_packages,
+_LINT_CHECKS = (
     pylint,
     mypy,
 )
 
+_ALL_CHECKS = (
+    test_python_packages,
+    *_LINT_CHECKS,
+)
+
+
+def lint_checks(endswith: str = '.py',
+                **filter_paths_args) -> Tuple[Callable, ...]:
+    return tuple(
+        filter_paths(endswith=endswith, **filter_paths_args)(function)
+        for function in _LINT_CHECKS)
+
 
 def all_checks(endswith: str = '.py',
                **filter_paths_args) -> Tuple[Callable, ...]: