(
threadsafety_filename: Path,
)
| 134 | |
| 135 | |
| 136 | def read_threadsafety_data( |
| 137 | threadsafety_filename: Path, |
| 138 | ) -> dict[str, ThreadSafetyEntry]: |
| 139 | threadsafety_data = {} |
| 140 | for line in threadsafety_filename.read_text(encoding="utf8").splitlines(): |
| 141 | line = line.strip() |
| 142 | if not line or line.startswith("#"): |
| 143 | continue |
| 144 | # Each line is of the form: function_name : level : [comment] |
| 145 | parts = line.split(":", 2) |
| 146 | if len(parts) < 2: |
| 147 | raise ValueError(f"Wrong field count in {line!r}") |
| 148 | name, level = parts[0].strip(), parts[1].strip() |
| 149 | if level not in _VALID_THREADSAFETY_LEVELS: |
| 150 | raise ValueError( |
| 151 | f"Unknown thread safety level {level!r} for {name!r}. " |
| 152 | f"Valid levels: {sorted(_VALID_THREADSAFETY_LEVELS)}" |
| 153 | ) |
| 154 | threadsafety_data[name] = ThreadSafetyEntry(name=name, level=level) |
| 155 | return threadsafety_data |
| 156 | |
| 157 | |
| 158 | def add_annotations(app: Sphinx, doctree: nodes.document) -> None: |
no test coverage detected
searching dependent graphs…