Skip to content

Usage filtering

Find Usages often mixes runtime references with references that are useful only in specific review modes. This feature adds usage-view filters that let you hide type-only references and test-source references without changing the underlying search result set.

Options

  • Hide type annotation usages removes references that occur inside type hints, including function parameters, return types, variable annotations, and common generic type expressions.
  • Hide test-source usages removes references from files marked as test sources and from pytest-style test files detected by BetterPy's pytest naming rules.

How to invoke

Run Find Usages (⌥F7 / Alt+F7) on a Python symbol, then use the BetterPy filter icons in the usage view toolbar:

  • BetterPy: Show Type Annotations
  • BetterPy: Show Test Usages

Example

# src/orders.py
class Order:
    ...


def submit(order: Order) -> None:
    ...


current = Order()
submit(current)


# tests/test_orders.py
from orders import Order

Order()

When type annotation usages are hidden, the order: Order annotation is removed from the usage view while the constructor call remains visible. When test-source usages are hidden, the reference in tests/test_orders.py is removed while production references remain visible.

What it deliberately avoids

  • Rewriting or deleting annotations.
  • Reclassifying source roots or changing project settings.
  • Treating imports as type-only or test-only without usage context.
  • Hiding production usages that happen to call test helper functions.

Notes

  • The master feature is gated by the Usage filtering setting under Settings | BetterPy | Code Quality & Safety | Find Usages.
  • The two filter options are shown under the master setting and can be toggled independently.