kensho-kfinance 3.2.15__py3-none-any.whl → 3.2.16__py3-none-any.whl

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.

Potentially problematic release.


This version of kensho-kfinance might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kensho-kfinance
3
- Version: 3.2.15
3
+ Version: 3.2.16
4
4
  Summary: Python CLI for kFinance
5
5
  Author-email: Luke Brown <luke.brown@kensho.com>, Michelle Keoy <michelle.keoy@kensho.com>, Keith Page <keith.page@kensho.com>, Matthew Rosen <matthew.rosen@kensho.com>, Nick Roshdieh <nick.roshdieh@kensho.com>
6
6
  Project-URL: source, https://github.com/kensho-technologies/kfinance
@@ -1,11 +1,11 @@
1
- kensho_kfinance-3.2.15.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
2
- kensho_kfinance-3.2.15.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
3
- kfinance/CHANGELOG.md,sha256=xJT27qCAAKJQM0y85678HYdKdwqM06p9Oc3U84T5pik,3796
1
+ kensho_kfinance-3.2.16.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
2
+ kensho_kfinance-3.2.16.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
3
+ kfinance/CHANGELOG.md,sha256=UXnVU8cFyiy6rD_D8vfDiictySiilcVpvgGL1ZXDGeE,3852
4
4
  kfinance/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
5
  kfinance/conftest.py,sha256=PFflyOx08XgmEA0rdugud7QEA7KqARmd22SH2dLTqrE,4091
6
6
  kfinance/mcp.py,sha256=LTzCIlqsDKRD-0Xcpa_P99-JmJ8duAneO_-GzM43kjw,424
7
7
  kfinance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- kfinance/version.py,sha256=CRv3L1Q_i86zRaBBd6DJtqrNBMlFDH42gmrAKivd6gU,706
8
+ kfinance/version.py,sha256=Ux2M8sElVaTs3q_AiwEr63O84-Wo4vL9ToWLkhLRvls,706
9
9
  kfinance/client/README.md,sha256=DA5vg4uz1JmJNiqvYywrj46YNhOr584WO8L83Ysx_Mk,372
10
10
  kfinance/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  kfinance/client/batch_request_handling.py,sha256=0r9x3-vXdpyKhfsIa6VZ9hovN60t3HB7nE3v5hnrSyI,6617
@@ -18,9 +18,9 @@ kfinance/client/server_thread.py,sha256=jUnt1YGoYDkqqz1MbCwd44zJs1T_Z2BCgvj75bdt
18
18
  kfinance/client/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  kfinance/client/models/currency_models.py,sha256=JfDZf-nATCyjThBw-Ky2BNvM-n2oHepBLIHMCIyCRUE,19201
20
20
  kfinance/client/models/date_and_period_models.py,sha256=KalZYTcDMkJiGBdaacpTwnaFSyDNgwku__rqdVtbs5Y,1091
21
- kfinance/client/models/decimal_with_unit.py,sha256=lfBvOQDk1cdWnqRh7oZoXe3_TbjNsbaV31KyosH_OoY,2911
21
+ kfinance/client/models/decimal_with_unit.py,sha256=Kf-GftBl3hVsFbKVR-FhW9c44YaAc9nib07w8JkeahE,3343
22
22
  kfinance/client/models/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- kfinance/client/models/tests/test_decimal_with_unit.py,sha256=7WlmVXFOFNHFqwsvXQvcgyPfa6noRm3-mLTcXz4GvRs,2202
23
+ kfinance/client/models/tests/test_decimal_with_unit.py,sha256=3Az_DZXTRQaxLddDCQrlD-XwU_ywGRWk3dXDzqFpBjc,2593
24
24
  kfinance/client/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  kfinance/client/tests/test_batch_requests.py,sha256=_V7GS7qbj_sRW49USgfp68TlYToUweruQWtQ8QwaEcg,11740
26
26
  kfinance/client/tests/test_client.py,sha256=GlK89ZOGL9bwrAUFUk8nua2ooKt0JYm7o_rpAfajFXA,4312
@@ -108,7 +108,7 @@ kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py
108
108
  kfinance/integrations/tool_calling/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
109
109
  kfinance/integrations/tool_calling/tests/test_tool_calling_models.py,sha256=5L8TpSVJmrjNzGcnERorpfeyrgLND_DL46ld5hVlcNw,2933
110
110
  kfinance/models/permission_models.py,sha256=G0so8ZOsD1YDsCM4he0z5R9M_shUbSRwD3hUDJdqZl0,635
111
- kensho_kfinance-3.2.15.dist-info/METADATA,sha256=mc-pn41xZA1Ow3P03Zl1URUUuRthvuxXcMWyG6QiczQ,6198
112
- kensho_kfinance-3.2.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
- kensho_kfinance-3.2.15.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
114
- kensho_kfinance-3.2.15.dist-info/RECORD,,
111
+ kensho_kfinance-3.2.16.dist-info/METADATA,sha256=P9RJ0_nTjCJPpHfwqv-jnNdQx4iPDfvyqZqbXmUdqFU,6198
112
+ kensho_kfinance-3.2.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
+ kensho_kfinance-3.2.16.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
114
+ kensho_kfinance-3.2.16.dist-info/RECORD,,
kfinance/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## v3.2.16
4
+ - Allow None and "NaN" for DecimalWithValue
5
+
3
6
  ## v3.2.15
4
7
  - Add smart line item validation with intelligent suggestions and descriptions to reduce token consumption by 75%
5
8
 
@@ -2,7 +2,7 @@ from copy import deepcopy
2
2
  from decimal import Decimal
3
3
  from typing import Any
4
4
 
5
- from pydantic import BaseModel, Field, model_validator
5
+ from pydantic import BaseModel, Field, field_validator, model_validator
6
6
  from typing_extensions import Self
7
7
 
8
8
  from kfinance.client.models.currency_models import ISO_CODE_TO_CURRENCY
@@ -20,11 +20,23 @@ class DecimalWithUnit(BaseModel):
20
20
  existing subclass like `Money` or `Shares` or create a new one.
21
21
  """
22
22
 
23
- value: Decimal
23
+ value: Decimal = Field(allow_inf_nan=True)
24
24
  unit: str
25
25
  # exclude conventional_decimals from serialization
26
26
  conventional_decimals: int = Field(exclude=True)
27
27
 
28
+ @field_validator("value", mode="before")
29
+ @classmethod
30
+ def convert_none_to_nan(cls, v: Any) -> Any:
31
+ """Convert None values to NaN.
32
+
33
+ Price data can include None for open prices.
34
+ https://kfinance.kensho.com/api/v1/pricing/37284793/2003-01-01/2024-12-31/month/adjusted
35
+ """
36
+ if v is None:
37
+ return Decimal("NaN")
38
+ return v
39
+
28
40
  @model_validator(mode="after")
29
41
  def quantize_value(self) -> Self:
30
42
  """Quantize the value at the end of the deserialization.
@@ -32,6 +32,15 @@ class TestDecimalWithUnit:
32
32
  )
33
33
  assert dwu.value == expected_value
34
34
 
35
+ @pytest.mark.parametrize("value", [None, "NaN"])
36
+ def test_null_nan_allowed(self, value: str | None):
37
+ """
38
+ WHEN a DecimalWithUnit gets deserialized with None or "NaN"
39
+ THEN the deserialized value is Decimal("NaN")
40
+ """
41
+ dwu = DecimalWithUnit.model_validate(dict(value=value, conventional_decimals=1, unit="foo"))
42
+ assert dwu.value.is_nan()
43
+
35
44
 
36
45
  class TestMoney:
37
46
  @pytest.mark.parametrize("currency, expected_conventional_decimals", [("USD", 2), ("BIF", 0)])
kfinance/version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '3.2.15'
32
- __version_tuple__ = version_tuple = (3, 2, 15)
31
+ __version__ = version = '3.2.16'
32
+ __version_tuple__ = version_tuple = (3, 2, 16)
33
33
 
34
34
  __commit_id__ = commit_id = None