How to distinguish marimo notebooks from any other python files robustly and efficiently?
At a glance
The community members are discussing an efficient and robust algorithm to recursively find all marimo notebooks in a directory. One community member shares a heuristic used by the marimo edit server, but another community member suggests it may not be robust enough, as it could incorrectly identify a non-marimo file as a marimo notebook. The community members discuss the possibility of using a custom file extension for marimo notebooks, but note that this would prevent them from being imported by Python's import statement. There is no explicitly marked answer in the comments.
I think this can't be a robust algorithm to test whether a python file is a marimo notebook. For example, run _is_marimo_file on this file exactly will return True 🤔
We thought about saving marimo notebooks with a custom extension for this reason (.mo.py), but such files can't be imported by Python's import statement.