> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# python-file-not-closed

> A Python function returns the contents of a locally opened file without closing its handle.

## What it flags

A locally opened handle must be closed after reading. The rule checks a direct call to the built-in open followed by returning the file contents with read or readlines. Returning the handle itself conveys ownership to the caller. Handles assigned to a global or nonlocal binding remain reachable outside the function.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.