This commit is contained in:
Anthony Sottile 2025-11-07 17:02:17 -05:00
parent 65175f3cf3
commit 37e2ba87a7
13 changed files with 134 additions and 0 deletions

16
pre_commit/request.py Normal file
View file

@ -0,0 +1,16 @@
from __future__ import annotations
import sys
import urllib.request
from typing import IO
from pre_commit.constants import VERSION
def fetch(url: str) -> IO[bytes]:
pyver = '.'.join(str(v) for v in sys.version_info[:3])
req = urllib.request.Request(
url,
headers={'User-Agent': f'pre-commit/{VERSION} python/{pyver}'},
)
return urllib.request.urlopen(req)