Given the contents of a Python file, extract the `script` metadata block with leading comment hashes removed and map its offsets to the original Python script. Given the following input string representing the contents of a Python script: ```python #!/usr/bin/env python3 # /// script # requires-python = '>=3.11' # dependencies = [ # 'requests<3', # 'rich', # ] # /// import requests print("
(contents: &[u8])
| 63 | /// |
| 64 | /// See: <https://peps.python.org/pep-0723/> |
| 65 | pub fn parse(contents: &[u8]) -> Option<Self> { |
| 66 | FINDER |
| 67 | .find_iter(contents) |
| 68 | .find_map(|index| Self::parse_at(contents, index)) |
| 69 | } |
| 70 | |
| 71 | fn parse_at(contents: &[u8], index: usize) -> Option<Self> { |
| 72 | // The opening pragma must be the first line, or immediately preceded by a newline. |
no outgoing calls
no test coverage detected