Skip to content

Commit 912078f

Browse files
authored
MNT support oder requests versions (#817)
* MNT support older requests versions * remove unnecessary comment
1 parent 9edcb30 commit 912078f

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

.github/conda/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ requirements:
1515
- python
1616
- pip
1717
- filelock
18-
- requests <=2.23
18+
- requests
1919
- tqdm
2020
- typing-extensions
2121
- packaging
@@ -24,7 +24,7 @@ requirements:
2424
- python
2525
- pip
2626
- filelock
27-
- requests <=2.23
27+
- requests
2828
- tqdm
2929
- typing-extensions
3030
- packaging

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ repos:
33
rev: v4.1.0
44
hooks:
55
- id: check-yaml
6+
exclude: .github/conda/meta.yaml
67
- id: end-of-file-fixer
78
- id: trailing-whitespace
89
- id: check-case-conflict

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_version() -> str:
1313

1414
install_requires = [
1515
"filelock",
16-
"requests>=2.27",
16+
"requests",
1717
"tqdm",
1818
"pyyaml",
1919
"typing-extensions>=3.7.4.3", # to be able to import TypeAlias

src/huggingface_hub/hf_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from typing import IO, Dict, Iterable, List, Optional, Tuple, Union
2323

2424
import requests
25-
from requests.exceptions import HTTPError, JSONDecodeError
25+
from requests.exceptions import HTTPError
2626

2727
from .constants import (
2828
ENDPOINT,
@@ -33,6 +33,7 @@
3333
)
3434
from .utils import logging
3535
from .utils._deprecation import _deprecate_positional_args
36+
from .utils._fixes import JSONDecodeError
3637
from .utils.endpoint_helpers import (
3738
AttributeDictionary,
3839
DatasetFilter,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# JSONDecodeError was introduced in requests=2.27 released in 2022.
2+
# This allows us to support older requests for users
3+
# More information: https://github.com/psf/requests/pull/5856
4+
try:
5+
from requests import JSONDecodeError # noqa
6+
except ImportError:
7+
try:
8+
from simplejson import JSONDecodeError # noqa
9+
except ImportError:
10+
from json import JSONDecodeError # noqa

0 commit comments

Comments
 (0)