Skip to content

file

file

File dataclass

File(*, path: Path)

A file path wrapper with glob matching, prefix checks, and test-file detection.

Delegates Path methods via __getattr__ so .suffix, .name, .parent, .exists() etc. work directly.

PathMatcher dataclass

PathMatcher(*, patterns: list[str])

A reusable set of glob patterns for matching file paths. Supports in operator.

categorize_files

categorize_files(
    paths: Iterable[str | Path], *, lang: str = "py"
) -> tuple[list[str], list[str], list[str]]

Split paths into source, test, and skipped buckets for a language.

A path that does not match the lang globs is skipped; otherwise it is classified as a test file (via :attr:File.is_test, which treats conftest.py and anything under a tests/ directory as tests) or as source.

Parameters:

Name Type Description Default
paths Iterable[str | Path]

File paths to categorize; blank entries are ignored.

required
lang str

Language key into LANG_GLOBS (defaults to "py"); unknown keys fall back to *.<lang>.

'py'

Returns:

Type Description
list[str]

A (source, test, skipped) tuple, each a sorted, de-duplicated list of

list[str]

path strings.