fds.sdk.utils 2.0.0__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: fds.sdk.utils
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: Utilities for interacting with FactSet APIs.
5
- Home-page: https://developer.factset.com
6
5
  License: Apache-2.0
7
6
  Keywords: FactSet,API,SDK
8
7
  Author: FactSet Research Systems
@@ -14,10 +13,12 @@ Classifier: Programming Language :: Python :: 3.9
14
13
  Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
- Requires-Dist: joserfc (>=0.9.0,<0.10.0)
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Dist: joserfc (>=0.9,<0.12)
18
18
  Requires-Dist: oauthlib (>=3.2.2,<4.0.0)
19
19
  Requires-Dist: requests (>=2.28.2,<3.0.0)
20
20
  Requires-Dist: requests-oauthlib (>=2.0.0,<3.0.0)
21
+ Project-URL: Homepage, https://developer.factset.com
21
22
  Description-Content-Type: text/markdown
22
23
 
23
24
  <img alt="FactSet" src="https://www.factset.com/hubfs/Assets/images/factset-logo.svg" height="56" width="290">
@@ -25,6 +26,7 @@ Description-Content-Type: text/markdown
25
26
  # FactSet SDK Utilities for Python
26
27
 
27
28
  [![PyPi](https://img.shields.io/pypi/v/fds.sdk.utils)](https://pypi.org/project/fds.sdk.utils/)
29
+ [![Anaconda-Server Badge](https://anaconda.org/factset/fds.sdk.utils/badges/version.svg)](https://anaconda.org/factset/fds.sdk.utils)
28
30
  [![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)
29
31
 
30
32
  This repository contains a collection of utilities that supports FactSet's SDK in Python and facilitate usage of FactSet
@@ -44,6 +46,12 @@ poetry add fds.sdk.utils
44
46
  pip install fds.sdk.utils
45
47
  ```
46
48
 
49
+ ### Conda
50
+
51
+ ```sh
52
+ conda install factset::fds.sdk.utils
53
+ ```
54
+
47
55
  ## Usage
48
56
 
49
57
  This library contains multiple modules, sample usage of each module is below.
@@ -3,6 +3,7 @@
3
3
  # FactSet SDK Utilities for Python
4
4
 
5
5
  [![PyPi](https://img.shields.io/pypi/v/fds.sdk.utils)](https://pypi.org/project/fds.sdk.utils/)
6
+ [![Anaconda-Server Badge](https://anaconda.org/factset/fds.sdk.utils/badges/version.svg)](https://anaconda.org/factset/fds.sdk.utils)
6
7
  [![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)
7
8
 
8
9
  This repository contains a collection of utilities that supports FactSet's SDK in Python and facilitate usage of FactSet
@@ -22,6 +23,12 @@ poetry add fds.sdk.utils
22
23
  pip install fds.sdk.utils
23
24
  ```
24
25
 
26
+ ### Conda
27
+
28
+ ```sh
29
+ conda install factset::fds.sdk.utils
30
+ ```
31
+
25
32
  ## Usage
26
33
 
27
34
  This library contains multiple modules, sample usage of each module is below.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "fds.sdk.utils"
3
- version = "2.0.0"
3
+ version = "2.1.0"
4
4
  description = "Utilities for interacting with FactSet APIs."
5
5
  authors = ["FactSet Research Systems"]
6
6
  license = "Apache-2.0"
@@ -21,15 +21,15 @@ python = "^3.8.0"
21
21
  requests-oauthlib = "^2.0.0"
22
22
  requests = "^2.28.2"
23
23
  oauthlib = "^3.2.2"
24
- joserfc = "^0.9.0"
24
+ joserfc = ">=0.9,<0.12"
25
25
 
26
26
  [tool.poetry.dev-dependencies]
27
- pytest = "^8.2.0"
28
- black = "^24.4.2"
27
+ pytest = "^8.3.4"
28
+ black = "^24.8.0"
29
29
  pytest-cov = "^5.0.0"
30
30
  pytest-mock = "^3.11.1"
31
- tox = "^4.8.0"
32
- tox-gh-actions = "^3.2.0"
31
+ tox = "^4.24.1"
32
+ tox-gh-actions = "^3.3.0"
33
33
 
34
34
  [tool.black]
35
35
  line-length = 120
@@ -187,11 +187,16 @@ class ConfidentialClient(OAuth2Client):
187
187
  if self._ssl_ca_cert:
188
188
  verify = self._ssl_ca_cert
189
189
 
190
+ headers = {
191
+ "User-Agent": CONSTS.USER_AGENT,
192
+ **(self._proxy_headers if self._proxy_headers else {}),
193
+ }
194
+
190
195
  res = self._requests_session.get(
191
196
  url=self._config[CONSTS.CONFIG_WELL_KNOWN_URI],
192
197
  proxies=self._proxy,
193
198
  verify=verify,
194
- headers=self._proxy_headers,
199
+ headers=headers,
195
200
  )
196
201
  log.debug("Request from well_known_uri completed with status: %s", res.status_code)
197
202
  log.debug("Response headers from well_known_uri were %s", res.headers)
@@ -242,7 +247,7 @@ class ConfidentialClient(OAuth2Client):
242
247
  if not self._cached_token:
243
248
  log.debug("Access Token cache is empty")
244
249
  return False
245
- if time.time() < self._cached_token[CONSTS.TOKEN_EXPIRES_AT]:
250
+ if time.time() < self._cached_token[CONSTS.TOKEN_EXPIRES_AT] - CONSTS.TOKEN_EXPIRY_OFFSET_SECS:
246
251
  return True
247
252
  else:
248
253
  log.debug("Cached access token has expired at %s", self._cached_token[CONSTS.TOKEN_EXPIRES_AT])
@@ -281,6 +286,7 @@ class ConfidentialClient(OAuth2Client):
281
286
  headers = {
282
287
  "Accept": "application/json",
283
288
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
289
+ "User-Agent": CONSTS.USER_AGENT,
284
290
  }
285
291
 
286
292
  if self._proxy_headers:
@@ -1,3 +1,6 @@
1
+ import platform
2
+
3
+
1
4
  class CONSTS:
2
5
  # confidential client assertion JWT
3
6
  CC_JWT_NOT_BEFORE_SECS = 5
@@ -14,6 +17,7 @@ class CONSTS:
14
17
  # access token
15
18
  TOKEN_ACCESS_TOKEN = "access_token"
16
19
  TOKEN_EXPIRES_AT = "expires_at"
20
+ TOKEN_EXPIRY_OFFSET_SECS = 30
17
21
 
18
22
  # config
19
23
  CONFIG_CLIENT_ID = "clientId"
@@ -24,5 +28,7 @@ class CONSTS:
24
28
  # default values
25
29
  FACTSET_WELL_KNOWN_URI = "https://auth.factset.com/.well-known/openid-configuration"
26
30
 
31
+ USER_AGENT = f"fds-sdk/python/utils/2.1.0 ({platform.system()}; Python {platform.python_version()})"
32
+
27
33
 
28
34
  CONSTS = CONSTS()
File without changes