Skip to content

Commit 361272a

Browse files
author
Val Brodsky
committed
Restore client.headers
1 parent d7c8759 commit 361272a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import urllib.parse
1010
from collections import defaultdict
1111
from datetime import datetime, timezone
12-
from typing import Any, List, Dict, Union, Optional, overload, Callable
12+
from typing import Any, List, Dict, MutableMapping, Union, Optional, overload, Callable
1313

1414
from labelbox.schema.search_filters import SearchFilter
1515
import requests
@@ -128,6 +128,10 @@ def _init_connection(self) -> requests.Session:
128128

129129
return connection
130130

131+
@property
132+
def headers(self) -> MutableMapping[str, str]:
133+
return self._connection.headers
134+
131135
def _default_headers(self):
132136
return {
133137
'Authorization': 'Bearer %s' % self.api_key,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
from unittest.mock import patch
4+
5+
from labelbox.client import Client
6+
7+
8+
# @patch.dict(os.environ, {'LABELBOX_API_KEY': 'bar'})
9+
def test_headers():
10+
client = Client(api_key="api_key", endpoint="http://localhost:8080/_gql")
11+
assert client.headers
12+
assert client.headers["Authorization"] == "Bearer api_key"
13+
assert client.headers["Content-Type"] == "application/json"
14+
assert client.headers["User-Agent"]
15+
assert client.headers["X-Python-Version"]

0 commit comments

Comments
 (0)