kensho-kfinance 3.2.7__tar.gz → 3.2.8__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.

Potentially problematic release.


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

Files changed (148) hide show
  1. {kensho_kfinance-3.2.7/kensho_kfinance.egg-info → kensho_kfinance-3.2.8}/PKG-INFO +1 -1
  2. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8/kensho_kfinance.egg-info}/PKG-INFO +1 -1
  3. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/CHANGELOG.md +3 -0
  4. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/line_items/line_item_models.py +1 -1
  5. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/line_items/line_item_tools.py +4 -3
  6. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/line_items/tests/test_line_item_tools.py +32 -0
  7. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/segments/segment_tools.py +4 -3
  8. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/segments/tests/test_segment_tools.py +37 -2
  9. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/statements/statement_tools.py +4 -3
  10. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/statements/tests/test_statement_tools.py +42 -0
  11. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/version.py +3 -3
  12. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/.coveragerc +0 -0
  13. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/.github/workflows/ci-lint.yml +0 -0
  14. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/.github/workflows/ci-test.yml +0 -0
  15. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/.github/workflows/python-publish.yml +0 -0
  16. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/.gitignore +0 -0
  17. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/.readthedocs.yaml +0 -0
  18. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/AUTHORS.md +0 -0
  19. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/CODE_OF_CONDUCT.md +0 -0
  20. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/CONTRIBUTING.md +0 -0
  21. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/LICENSE +0 -0
  22. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/README.md +0 -0
  23. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/build_tool_calling_documentation.py +0 -0
  24. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/conf.py +0 -0
  25. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/index.rst +0 -0
  26. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/kfinance.rst +0 -0
  27. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/requirements.txt +0 -0
  28. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/templates/apidoc/package.rst_t +0 -0
  29. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/templates/apidoc/toc.rst_t +0 -0
  30. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/docs/tool_calling.rst +0 -0
  31. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/example_notebooks/basic_usage.ipynb +0 -0
  32. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/example_notebooks/tool_calling/langchain/anthropic_langchain_tool_calling.ipynb +0 -0
  33. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/example_notebooks/tool_calling/langchain/google_gemini_langchain_tool_calling.ipynb +0 -0
  34. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/example_notebooks/tool_calling/langchain/openai_langchain_tool_calling.ipynb +0 -0
  35. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/example_notebooks/tool_calling/non-langchain/anthropic_tool_calling.ipynb +0 -0
  36. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/example_notebooks/tool_calling/non-langchain/google_gemini_tool_calling.ipynb +0 -0
  37. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/example_notebooks/tool_calling/non-langchain/openai_langchain_tool_calling.ipynb +0 -0
  38. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/images/colab_logo_32px.png +0 -0
  39. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/justfile +0 -0
  40. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kensho_kfinance.egg-info/SOURCES.txt +0 -0
  41. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kensho_kfinance.egg-info/dependency_links.txt +0 -0
  42. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kensho_kfinance.egg-info/requires.txt +0 -0
  43. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kensho_kfinance.egg-info/top_level.txt +0 -0
  44. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/__init__.py +0 -0
  45. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/README.md +0 -0
  46. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/__init__.py +0 -0
  47. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/batch_request_handling.py +0 -0
  48. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/fetch.py +0 -0
  49. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/industry_models.py +0 -0
  50. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/kfinance.py +0 -0
  51. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/meta_classes.py +0 -0
  52. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/models/__init__.py +0 -0
  53. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/models/currency_models.py +0 -0
  54. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/models/date_and_period_models.py +0 -0
  55. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/models/decimal_with_unit.py +0 -0
  56. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/models/tests/__init__.py +0 -0
  57. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/models/tests/test_decimal_with_unit.py +0 -0
  58. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/permission_models.py +0 -0
  59. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/server_thread.py +0 -0
  60. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/tests/__init__.py +0 -0
  61. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/tests/test_batch_requests.py +0 -0
  62. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/tests/test_client.py +0 -0
  63. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/tests/test_fetch.py +0 -0
  64. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/tests/test_group_objects.py +0 -0
  65. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/client/tests/test_objects.py +0 -0
  66. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/conftest.py +0 -0
  67. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/README.md +0 -0
  68. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/__init__.py +0 -0
  69. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/business_relationships/__init__.py +0 -0
  70. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/business_relationships/business_relationship_models.py +0 -0
  71. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/business_relationships/business_relationship_tools.py +0 -0
  72. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/business_relationships/tests/__init__.py +0 -0
  73. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/business_relationships/tests/test_business_relationship_tools.py +0 -0
  74. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/capitalizations/__init__.py +0 -0
  75. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/capitalizations/capitalization_models.py +0 -0
  76. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/capitalizations/capitalization_tools.py +0 -0
  77. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/capitalizations/tests/__init__.py +0 -0
  78. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/capitalizations/tests/test_capitalization_models.py +0 -0
  79. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/capitalizations/tests/test_capitalization_tools.py +0 -0
  80. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/companies/__init__.py +0 -0
  81. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/companies/company_identifiers.py +0 -0
  82. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/companies/company_models.py +0 -0
  83. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/companies/company_tools.py +0 -0
  84. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/companies/tests/__init__.py +0 -0
  85. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/companies/tests/test_company_tools.py +0 -0
  86. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/competitors/__init__.py +0 -0
  87. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/competitors/competitor_models.py +0 -0
  88. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/competitors/competitor_tools.py +0 -0
  89. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/competitors/tests/__init__.py +0 -0
  90. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/competitors/tests/test_competitor_tools.py +0 -0
  91. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/cusip_and_isin/__init__.py +0 -0
  92. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/cusip_and_isin/cusip_and_isin_tools.py +0 -0
  93. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/cusip_and_isin/tests/__init__.py +0 -0
  94. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/cusip_and_isin/tests/test_cusip_and_isin_tools.py +0 -0
  95. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/earnings/__init__.py +0 -0
  96. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/earnings/earning_models.py +0 -0
  97. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/earnings/earning_tools.py +0 -0
  98. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/earnings/tests/__init__.py +0 -0
  99. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/earnings/tests/test_earnings_tools.py +0 -0
  100. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/line_items/__init__.py +0 -0
  101. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/line_items/tests/__init__.py +0 -0
  102. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/mergers_and_acquisitions/__init__.py +0 -0
  103. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_models.py +0 -0
  104. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/mergers_and_acquisitions/merger_and_acquisition_tools.py +0 -0
  105. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/mergers_and_acquisitions/tests/__init__.py +0 -0
  106. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/mergers_and_acquisitions/tests/test_merger_and_acquisition_tools.py +0 -0
  107. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/prices/__init__.py +0 -0
  108. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/prices/price_models.py +0 -0
  109. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/prices/price_tools.py +0 -0
  110. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/prices/tests/__init__.py +0 -0
  111. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/prices/tests/test_price_models.py +0 -0
  112. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/prices/tests/test_price_tools.py +0 -0
  113. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/segments/__init__.py +0 -0
  114. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/segments/segment_models.py +0 -0
  115. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/segments/tests/__init__.py +0 -0
  116. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/statements/__init__.py +0 -0
  117. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/statements/statement_models.py +0 -0
  118. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/domains/statements/tests/__init__.py +0 -0
  119. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/README.md +0 -0
  120. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/__init__.py +0 -0
  121. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/local_mcp/__init__.py +0 -0
  122. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/local_mcp/kfinance_mcp.py +0 -0
  123. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/local_mcp/local_mcp.py +0 -0
  124. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tests/__init__.py +0 -0
  125. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tests/test_example_notebook.py +0 -0
  126. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/README.md +0 -0
  127. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/__init__.py +0 -0
  128. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/all_tools.py +0 -0
  129. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/prompts.py +0 -0
  130. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/static_tools/README.md +0 -0
  131. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/static_tools/__init__.py +0 -0
  132. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/static_tools/get_latest.py +0 -0
  133. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/static_tools/get_n_quarters_ago.py +0 -0
  134. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/static_tools/tests/__init__.py +0 -0
  135. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/static_tools/tests/test_get_lastest.py +0 -0
  136. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/static_tools/tests/test_get_n_quarters_ago.py +0 -0
  137. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/tests/__init__.py +0 -0
  138. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/tests/test_tool_calling_models.py +0 -0
  139. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/integrations/tool_calling/tool_calling_models.py +0 -0
  140. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/mcp.py +0 -0
  141. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/models/permission_models.py +0 -0
  142. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/kfinance/py.typed +0 -0
  143. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/pyproject.toml +0 -0
  144. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/scripts/copyright_line_check.sh +0 -0
  145. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/scripts/lint.sh +0 -0
  146. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/scripts/test.sh +0 -0
  147. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/setup.cfg +0 -0
  148. {kensho_kfinance-3.2.7 → kensho_kfinance-3.2.8}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kensho-kfinance
3
- Version: 3.2.7
3
+ Version: 3.2.8
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kensho-kfinance
3
- Version: 3.2.7
3
+ Version: 3.2.8
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,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ # v3.2.8
4
+ - Added support for None to LineItemResponse & empty behavior for line items, segments, and statements
5
+
3
6
  # v3.2.7
4
7
  - Fix validator for UnifiedIdTripleResponse
5
8
 
@@ -6,7 +6,7 @@ from pydantic import BaseModel
6
6
 
7
7
 
8
8
  class LineItemResponse(BaseModel):
9
- line_item: dict[str, Decimal]
9
+ line_item: dict[str, Decimal | None]
10
10
 
11
11
 
12
12
  class LineItemType(TypedDict):
@@ -109,9 +109,10 @@ class GetFinancialLineItemFromIdentifiers(KfinanceTool):
109
109
  and len(line_item_responses) > 1
110
110
  ):
111
111
  for line_item_response in line_item_responses.values():
112
- most_recent_year = max(line_item_response.line_item.keys())
113
- most_recent_year_data = line_item_response.line_item[most_recent_year]
114
- line_item_response.line_item = {most_recent_year: most_recent_year_data}
112
+ if line_item_response.line_item:
113
+ most_recent_year = max(line_item_response.line_item.keys())
114
+ most_recent_year_data = line_item_response.line_item[most_recent_year]
115
+ line_item_response.line_item = {most_recent_year: most_recent_year_data}
115
116
 
116
117
  return GetFinancialLineItemFromIdentifiersResp(
117
118
  results=line_item_responses, errors=list(id_triple_resp.errors.values())
@@ -86,6 +86,38 @@ class TestGetFinancialLineItemFromCompanyIds:
86
86
  response = tool.run(args.model_dump(mode="json"))
87
87
  assert response == expected_response
88
88
 
89
+ def test_empty_most_recent_request(self, requests_mock: Mocker, mock_client: Client) -> None:
90
+ """
91
+ GIVEN the GetFinancialLineItemFromIdentifiers tool
92
+ WHEN we request most recent line items for multiple companies
93
+ THEN we only get back the most recent line item for each company
94
+ UNLESS no line items exist
95
+ """
96
+
97
+ company_ids = [1, 2]
98
+
99
+ c_1_line_item_resp = LineItemResponse(line_item={})
100
+ c_2_line_item_resp = LineItemResponse(line_item={"2024": Decimal(14208000000)})
101
+ expected_response = GetFinancialLineItemFromIdentifiersResp(
102
+ results={"C_1": c_1_line_item_resp, "C_2": c_2_line_item_resp},
103
+ )
104
+
105
+ requests_mock.get(
106
+ url=f"https://kfinance.kensho.com/api/v1/line_item/1/revenue/none/none/none/none/none",
107
+ json={"line_item": {}},
108
+ )
109
+ requests_mock.get(
110
+ url=f"https://kfinance.kensho.com/api/v1/line_item/2/revenue/none/none/none/none/none",
111
+ json=self.line_item_resp,
112
+ )
113
+ tool = GetFinancialLineItemFromIdentifiers(kfinance_client=mock_client)
114
+ args = GetFinancialLineItemFromIdentifiersArgs(
115
+ identifiers=[f"{COMPANY_ID_PREFIX}{company_id}" for company_id in company_ids],
116
+ line_item="revenue",
117
+ )
118
+ response = tool.run(args.model_dump(mode="json"))
119
+ assert response == expected_response
120
+
89
121
  def test_line_items_and_aliases_included_in_schema(self, mock_client: Client):
90
122
  """
91
123
  GIVEN a GetFinancialLineItemFromCompanyIds tool
@@ -98,9 +98,10 @@ class GetSegmentsFromIdentifiers(KfinanceTool):
98
98
  and len(segments_responses) > 1
99
99
  ):
100
100
  for segments_response in segments_responses.values():
101
- most_recent_year = max(segments_response.segments.keys())
102
- most_recent_year_data = segments_response.segments[most_recent_year]
103
- segments_response.segments = {most_recent_year: most_recent_year_data}
101
+ if segments_response.segments:
102
+ most_recent_year = max(segments_response.segments.keys())
103
+ most_recent_year_data = segments_response.segments[most_recent_year]
104
+ segments_response.segments = {most_recent_year: most_recent_year_data}
104
105
 
105
106
  return GetSegmentsFromIdentifiersResp(
106
107
  results=segments_responses, errors=list(id_triple_resp.errors.values())
@@ -63,8 +63,8 @@ class TestGetSegmentsFromIdentifier:
63
63
  def test_most_recent_request(self, requests_mock: Mocker, mock_client: Client) -> None:
64
64
  """
65
65
  GIVEN the GetFinancialLineItemFromIdentifiers tool
66
- WHEN we request most recent statement for multiple companies
67
- THEN we only get back the most recent statement for each company
66
+ WHEN we request most recent segment for multiple companies
67
+ THEN we only get back the most recent segment for each company
68
68
  """
69
69
 
70
70
  company_ids = [1, 2]
@@ -90,3 +90,38 @@ class TestGetSegmentsFromIdentifier:
90
90
  )
91
91
  response = tool.run(args.model_dump(mode="json"))
92
92
  assert response == expected_response
93
+
94
+ def test_empty_most_recent_request(self, requests_mock: Mocker, mock_client: Client) -> None:
95
+ """
96
+ GIVEN the GetFinancialLineItemFromIdentifiers tool
97
+ WHEN we request most recent segment for multiple companies
98
+ THEN we only get back the most recent segment for each company
99
+ UNLESS no segments exist
100
+ """
101
+
102
+ company_ids = [1, 2]
103
+ expected_response = GetSegmentsFromIdentifiersResp.model_validate(
104
+ {
105
+ "results": {
106
+ "C_1": {"segments": {}},
107
+ "C_2": {"segments": {"2021": self.segments_response["segments"]["2021"]}},
108
+ }
109
+ }
110
+ )
111
+
112
+ requests_mock.get(
113
+ url=f"https://kfinance.kensho.com/api/v1/segments/1/business/none/none/none/none/none",
114
+ json={"segments": {}},
115
+ )
116
+ requests_mock.get(
117
+ url=f"https://kfinance.kensho.com/api/v1/segments/2/business/none/none/none/none/none",
118
+ json=self.segments_response,
119
+ )
120
+
121
+ tool = GetSegmentsFromIdentifiers(kfinance_client=mock_client)
122
+ args = GetSegmentsFromIdentifiersArgs(
123
+ identifiers=[f"{COMPANY_ID_PREFIX}{company_id}" for company_id in company_ids],
124
+ segment_type=SegmentType.business,
125
+ )
126
+ response = tool.run(args.model_dump(mode="json"))
127
+ assert response == expected_response
@@ -105,9 +105,10 @@ class GetFinancialStatementFromIdentifiers(KfinanceTool):
105
105
  and len(statement_responses) > 1
106
106
  ):
107
107
  for statement_response in statement_responses.values():
108
- most_recent_year = max(statement_response.statements.keys())
109
- most_recent_year_data = statement_response.statements[most_recent_year]
110
- statement_response.statements = {most_recent_year: most_recent_year_data}
108
+ if statement_response.statements:
109
+ most_recent_year = max(statement_response.statements.keys())
110
+ most_recent_year_data = statement_response.statements[most_recent_year]
111
+ statement_response.statements = {most_recent_year: most_recent_year_data}
111
112
 
112
113
  return GetFinancialStatementFromIdentifiersResp(
113
114
  results=statement_responses, errors=list(id_triple_resp.errors.values())
@@ -105,3 +105,45 @@ class TestGetFinancialStatementFromIdentifiers:
105
105
  )
106
106
  response = tool.run(args.model_dump(mode="json"))
107
107
  assert response == expected_response
108
+
109
+ def test_empty_most_recent_request(self, requests_mock: Mocker, mock_client: Client) -> None:
110
+ """
111
+ GIVEN the GetFinancialStatementFromIdentifiers tool
112
+ WHEN we request most recent statement for multiple companies
113
+ THEN we only get back the most recent statement for each company
114
+ UNLESS no statements exist
115
+ """
116
+
117
+ company_ids = [1, 2]
118
+ expected_response = GetFinancialStatementFromIdentifiersResp.model_validate(
119
+ {
120
+ "results": {
121
+ "C_1": {"statements": {}},
122
+ "C_2": {
123
+ "statements": {
124
+ "2021": {
125
+ "Revenues": "8243000000.000000",
126
+ "Total Revenues": "8243000000.000000",
127
+ }
128
+ }
129
+ },
130
+ }
131
+ }
132
+ )
133
+
134
+ requests_mock.get(
135
+ url=f"https://kfinance.kensho.com/api/v1/statements/1/income_statement/none/none/none/none/none",
136
+ json={"statements": {}},
137
+ )
138
+ requests_mock.get(
139
+ url=f"https://kfinance.kensho.com/api/v1/statements/2/income_statement/none/none/none/none/none",
140
+ json=self.statement_resp,
141
+ )
142
+
143
+ tool = GetFinancialStatementFromIdentifiers(kfinance_client=mock_client)
144
+ args = GetFinancialStatementFromIdentifiersArgs(
145
+ identifiers=[f"{COMPANY_ID_PREFIX}{company_id}" for company_id in company_ids],
146
+ statement=StatementType.income_statement,
147
+ )
148
+ response = tool.run(args.model_dump(mode="json"))
149
+ assert response == expected_response
@@ -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.7'
32
- __version_tuple__ = version_tuple = (3, 2, 7)
31
+ __version__ = version = '3.2.8'
32
+ __version_tuple__ = version_tuple = (3, 2, 8)
33
33
 
34
- __commit_id__ = commit_id = 'ga53013bfe'
34
+ __commit_id__ = commit_id = 'ge9fdf681b'
File without changes