Skip to content

fix: replace bare open() calls with context managers in cardiology_detect.py #1171

Description

@rtmalikian

Problem

pyhealth/tasks/cardiology_detect.py uses bare open().readlines() calls in 5 places (lines 76, 172, 266, 360, 454). These rely on CPython reference counting for file handle cleanup, which is not guaranteed across all Python implementations.

Solution

Replace label_content = open(path, "r").readlines() with:

with open(path, "r") as f:
    label_content = f.readlines()

Affected Files

  • pyhealth/tasks/cardiology_detect.py (5 occurrences)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions