kensho-kfinance 3.2.14__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.14
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.14.dist-info/licenses/AUTHORS.md,sha256=0h9ClbI0pu1oKj1M28ROUsaxrbZg-6ukQGl6X4y9noI,68
2
- kensho_kfinance-3.2.14.dist-info/licenses/LICENSE,sha256=bsY4blvSgq6o0FMQ3RXa2NCgco--nHCCchLXzxr6kms,83
3
- kfinance/CHANGELOG.md,sha256=cpqPSoLOmQig4GzO2LYSbyCBlkhXSRCaW0Ki1cqpBlk,3669
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=xrCzWghWTUXSJlGcGHQKuZSYpI9ryUZDYdJZAz258T8,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
@@ -48,7 +48,7 @@ kfinance/domains/companies/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
48
48
  kfinance/domains/companies/tests/test_company_tools.py,sha256=ijZF6tWswvtD9YpjtGAPsS76nyOf6aaNPB_u_v-EAwQ,5587
49
49
  kfinance/domains/competitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  kfinance/domains/competitors/competitor_models.py,sha256=HAEn2AzKZNusclsFzyAufpS-627RfRGL4Vw1AiT_Ek0,747
51
- kfinance/domains/competitors/competitor_tools.py,sha256=k1zyr03gbnIrQ8IaENaZlVE8RiiW_77MqnArWzKa02M,2524
51
+ kfinance/domains/competitors/competitor_tools.py,sha256=ZjKZfr33Wh3lbstsQdFOHsbs9fLZ_flDWNALtFB6UxI,2590
52
52
  kfinance/domains/competitors/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  kfinance/domains/competitors/tests/test_competitor_tools.py,sha256=o7y4huxc5DUTNBm5HO-QArr-X9wEcXtsX5umuQ3owz4,2552
54
54
  kfinance/domains/cusip_and_isin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -61,10 +61,10 @@ kfinance/domains/earnings/earning_tools.py,sha256=AmHZQKTGExPPxyDdjhrn5CVLvWr6xM
61
61
  kfinance/domains/earnings/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  kfinance/domains/earnings/tests/test_earnings_tools.py,sha256=qGhdWI1s4uEjF6XtFC0f1nlAths1H6xfym-iJyBpwBo,6998
63
63
  kfinance/domains/line_items/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- kfinance/domains/line_items/line_item_models.py,sha256=bjSfXy0dxpUXr5MGU4FchSR2kz8J5TwyPHcW-TCDxb4,45537
65
- kfinance/domains/line_items/line_item_tools.py,sha256=bP1lbWVGg32XG6i8uhg8xtc9ttlRpoSDDI5NPxm6g90,5347
64
+ kfinance/domains/line_items/line_item_models.py,sha256=orSPa5tiIN73f70aRbvkLglUk0ZbvqyaEPQJWp2OOfA,65241
65
+ kfinance/domains/line_items/line_item_tools.py,sha256=ZfWQxdWAaIOtquh_SGuuoRkvp9f1LsFlt-In1F9NSTw,8643
66
66
  kfinance/domains/line_items/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
- kfinance/domains/line_items/tests/test_line_item_tools.py,sha256=vgxJsPbQG1msXZKTfpyHSzUfhw0GvfxZ041T7J-56hU,5499
67
+ kfinance/domains/line_items/tests/test_line_item_tools.py,sha256=_72HW41KIvbZs_25_pN6r0oUHrvbOi2Q6IIk8evJ8VE,11573
68
68
  kfinance/domains/mergers_and_acquisitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_models.py,sha256=WAWyBCgYMZj8NLz6nq_sW5MRg_UU5_F9jUUoQ_bcmsM,1893
70
70
  kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py,sha256=Yx3_TxTWdPcIiOddyAJEddpWc6L-fgx1-JoMtqdPtWQ,7156
@@ -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.14.dist-info/METADATA,sha256=bM48OTokWF9AfHHIiE5Xi39QQ88MUYfMZYOcuLOZB7c,6198
112
- kensho_kfinance-3.2.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
- kensho_kfinance-3.2.14.dist-info/top_level.txt,sha256=kT_kNwVhfQoOAecY8W7uYah5xaHMoHoAdBIvXh6DaKM,9
114
- kensho_kfinance-3.2.14.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,4 +1,11 @@
1
1
  # Changelog
2
+
3
+ ## v3.2.16
4
+ - Allow None and "NaN" for DecimalWithValue
5
+
6
+ ## v3.2.15
7
+ - Add smart line item validation with intelligent suggestions and descriptions to reduce token consumption by 75%
8
+
2
9
  # 3.2.14
3
10
  - Fix Capitalizations validator to handle nulls
4
11
 
@@ -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)])
@@ -1,3 +1,5 @@
1
+ from typing import Type
2
+
1
3
  from kfinance.client.batch_request_handling import Task, process_tasks_in_thread_pool_executor
2
4
  from kfinance.client.permission_models import Permission
3
5
  from kfinance.domains.competitors.competitor_models import CompetitorResponse, CompetitorSource
@@ -20,7 +22,7 @@ class GetCompetitorsFromIdentifiersResp(ToolRespWithErrors):
20
22
  class GetCompetitorsFromIdentifiers(KfinanceTool):
21
23
  name: str = "get_competitors_from_identifiers"
22
24
  description: str = "Retrieves a list of company_id and company_name that are competitors for a list of companies, optionally filtered by the source of the competitor information."
23
- args_schema = GetCompetitorsFromIdentifiersArgs
25
+ args_schema: Type[GetCompetitorsFromIdentifiersArgs] = GetCompetitorsFromIdentifiersArgs
24
26
  accepted_permissions: set[Permission] | None = {Permission.CompetitorsPermission}
25
27
 
26
28
  def _run(