Skip to content

Replace print() statements with warnings.warn() in production code #1044

@suhaan-24

Description

@suhaan-24

Several functions in the codebase use print() to notify users of non-critical conditions (e.g. cohort too small, SNP filter returned no results). This bypasses Python's standard warnings module, meaning users cannot filter or suppress these messages programmatically.
Affected locations:

  • hapclust.py — lines 405, 712
  • dipclust.py — lines 543, 610
  • sample_metadata.py — line 1468
    Each print(...) should be replaced with warnings.warn(...) using stacklevel=2 so the warning points to the caller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions