(session: requests.Session, url: str)
| 148 | |
| 149 | |
| 150 | def _check_external(session: requests.Session, url: str) -> tuple[bool, str]: |
| 151 | if url.startswith("http://localhost") or url.startswith("http://127.0.0.1"): |
| 152 | return True, "skip-localhost" |
| 153 | for pat in IGNORE_EXTERNAL_GLOBS: |
| 154 | if _matches_glob(url, pat): |
| 155 | return True, "ignored-glob" |
| 156 | try: |
| 157 | r = session.head(url, allow_redirects=True, timeout=REQUEST_TIMEOUT) |
| 158 | if r.status_code in (405, 501): |
| 159 | r = session.get( |
| 160 | url, allow_redirects=True, timeout=REQUEST_TIMEOUT, stream=True |
| 161 | ) |
| 162 | r.close() |
| 163 | if r.status_code == 403 and _is_github_host(url): |
| 164 | return True, "skip-github-403" |
| 165 | if 200 <= r.status_code < 400: |
| 166 | return True, str(r.status_code) |
| 167 | return False, f"HTTP {r.status_code}" |
| 168 | except requests.RequestException as e: |
| 169 | return False, str(e) |
| 170 | |
| 171 | |
| 172 | def collect_checks(site_root: Path) -> list[tuple[Path, str, str, str]]: |
no test coverage detected
searching dependent graphs…