Skip to content

Commit d51da5d

Browse files
committed
tweak heareds
1 parent f62e4b2 commit d51da5d

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

.github/workflows/main.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222

2323
env:
2424
CIRUN: true
25-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2625

2726
steps:
2827
- name: Checkout

fsspec/implementations/gist.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,24 @@ def __init__(
6565
@property
6666
def kw(self):
6767
"""Auth parameters passed to 'requests' if we have username/token."""
68-
if self.username is not None and self.token is not None:
69-
return {"auth": (self.username, self.token), **self.request_kw}
70-
elif self.token is not None:
71-
return {"headers": {"Authorization": f"Bearer {self.token}"}}
72-
return self.request_kw
68+
kw = {
69+
"headers": {
70+
"Accept": "application/vnd.github+json",
71+
"X-GitHub-Api-Version": "2022-11-28",
72+
}
73+
}
74+
kw.update(self.request_kw)
75+
if self.username and self.token:
76+
kw["auth"] = (self.username, self.token)
77+
elif self.token:
78+
kw["headers"]["Authorization"] = f"Bearer {self.token}"
79+
return kw
7380

7481
def _fetch_gist_metadata(self):
7582
"""
7683
Fetch the JSON metadata for this gist (possibly for a specific revision).
7784
"""
85+
breakpoint()
7886
if self.sha:
7987
url = self.gist_rev_url.format(gist_id=self.gist_id, sha=self.sha)
8088
else:

fsspec/implementations/tests/test_gist.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import sys
32

43
import pytest
@@ -9,15 +8,13 @@
98
if sys.version_info[:2] != (3, 12):
109
pytest.skip("Too many tests bust rate limit", allow_module_level=True)
1110

12-
token = os.getenv("GH_TOKEN", None)
13-
1411

1512
@pytest.mark.parametrize(
1613
"gist_id,sha",
17-
[("2656908684d3965b80c2", "2fb2f12f332f7e242b1a2af1f41e30ddf99f24c7")],
14+
[("d5d7b521d0e5fec8adfc5652b8f3242c", None)],
1815
)
1916
def test_gist_public_all_files(gist_id, sha):
20-
fs = fsspec.filesystem("gist", gist_id=gist_id, sha=sha, token=token)
17+
fs = fsspec.filesystem("gist", gist_id=gist_id, sha=sha)
2118
# Listing
2219
all_files = fs.ls("")
2320
assert len(all_files) == 2
@@ -32,16 +29,14 @@ def test_gist_public_all_files(gist_id, sha):
3229
"gist_id,sha,file",
3330
[
3431
(
35-
"2656908684d3965b80c2",
36-
"2fb2f12f332f7e242b1a2af1f41e30ddf99f24c7",
37-
"distributed_error_logs_PY3_7-3-2016",
32+
"d5d7b521d0e5fec8adfc5652b8f3242c",
33+
None,
34+
"ex1.ipynb",
3835
)
3936
],
4037
)
4138
def test_gist_public_one_file(gist_id, sha, file):
42-
fs = fsspec.filesystem(
43-
"gist", gist_id=gist_id, sha=sha, filenames=[file], token=token
44-
)
39+
fs = fsspec.filesystem("gist", gist_id=gist_id, sha=sha, filenames=[file])
4540
# Listing
4641
all_files = fs.ls("")
4742
assert len(all_files) == 1
@@ -57,16 +52,14 @@ def test_gist_public_one_file(gist_id, sha, file):
5752
[
5853
(
5954
"2656908684d3965b80c2",
60-
"2fb2f12f332f7e242b1a2af1f41e30ddf99f24c7",
55+
"d5d7b521d0e5fec8adfc5652b8f3242c",
6156
"file-that-doesnt-exist.py",
6257
)
6358
],
6459
)
6560
def test_gist_public_missing_file(gist_id, sha, file):
6661
with pytest.raises(FileNotFoundError):
67-
fsspec.filesystem(
68-
"gist", gist_id=gist_id, sha=sha, filenames=[file], token=token
69-
)
62+
fsspec.filesystem("gist", gist_id=gist_id, sha=sha, filenames=[file])
7063

7164

7265
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)