Skip to content

Commit 785ce04

Browse files
vbrodskyVal Brodsky
authored andcommitted
[PLT-1437] Restore client.headers (#1781)
1 parent 70f30b0 commit 785ce04

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
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
12+
from typing import Any, List, Dict, Union, Optional, overload, Callable
13+
from types import MappingProxyType
1314

1415
import requests
1516
import requests.exceptions
@@ -126,6 +127,10 @@ def _init_connection(self) -> requests.Session:
126127

127128
return connection
128129

130+
@property
131+
def headers(self) -> MappingProxyType:
132+
return self._connection.headers
133+
129134
def _default_headers(self):
130135
return {
131136
'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)