fmp-data 2.6.0__tar.gz → 2.7.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.
- {fmp_data-2.6.0 → fmp_data-2.7.0}/.gitignore +12 -5
- {fmp_data-2.6.0 → fmp_data-2.7.0}/PKG-INFO +40 -25
- {fmp_data-2.6.0 → fmp_data-2.7.0}/README.md +37 -23
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/__init__.py +20 -0
- fmp_data-2.7.0/fmp_data/_redaction.py +195 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/_version.py +2 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/alternative/async_client.py +43 -19
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/alternative/client.py +36 -16
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/alternative/endpoints.py +14 -13
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/alternative/mapping.py +22 -19
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/alternative/schema.py +3 -14
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/base.py +413 -49
- fmp_data-2.7.0/fmp_data/batch/_csv_utils.py +182 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/batch/async_client.py +110 -66
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/batch/client.py +106 -51
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/batch/endpoints.py +40 -36
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/batch/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/cache/__init__.py +7 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/cache/config.py +40 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/cache/file.py +2 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/cache/redis_backend.py +14 -3
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/__init__.py +2 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/async_client.py +246 -115
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/client.py +233 -113
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/endpoints.py +96 -67
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/hints.py +7 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/mapping.py +62 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/models.py +22 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/company/schema.py +19 -8
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/config.py +168 -23
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/economics/async_client.py +27 -8
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/economics/client.py +28 -8
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/economics/endpoints.py +7 -7
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/economics/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/exceptions.py +26 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/fundamental/async_client.py +74 -34
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/fundamental/client.py +67 -29
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/fundamental/endpoints.py +22 -21
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/fundamental/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/fundamental/models.py +108 -4
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/index/async_client.py +21 -6
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/index/client.py +18 -6
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/index/endpoints.py +6 -6
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/index/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/institutional/async_client.py +99 -47
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/institutional/client.py +92 -46
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/institutional/endpoints.py +22 -22
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/institutional/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/institutional/models.py +3 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/intelligence/__init__.py +12 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/intelligence/async_client.py +240 -43
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/intelligence/client.py +212 -39
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/intelligence/endpoints.py +284 -53
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/intelligence/mapping.py +304 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/intelligence/models.py +209 -7
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/investment/async_client.py +45 -18
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/investment/client.py +40 -14
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/investment/endpoints.py +14 -14
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/investment/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/config.py +16 -4
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/embedding.py +41 -5
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/hints.py +12 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/registry.py +2 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/validation.py +2 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/vector_store.py +22 -13
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/logger.py +229 -75
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/async_client.py +119 -44
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/client.py +93 -43
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/endpoints.py +43 -34
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/cli.py +99 -54
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/server.py +3 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/setup.py +80 -75
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/tools_manifest.py +15 -8
- fmp_data-2.7.0/fmp_data/mcp/utils.py +618 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/models.py +38 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/rate_limit.py +3 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/schema.py +63 -22
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/sec/async_client.py +81 -51
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/sec/client.py +80 -50
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/sec/endpoints.py +11 -11
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/sec/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/technical/async_client.py +32 -26
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/technical/client.py +32 -26
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/technical/endpoints.py +11 -10
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/technical/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/technical/schema.py +3 -4
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/tool_binding.py +3 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/transcripts/async_client.py +14 -5
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/transcripts/client.py +14 -4
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/transcripts/endpoints.py +4 -4
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/transcripts/mapping.py +4 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/pyproject.toml +33 -17
- fmp_data-2.7.0/tests/e2e/harness.py +588 -0
- fmp_data-2.7.0/tests/e2e/test_client_sweep.py +55 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/e2e/test_live_signatures.py +3 -2
- fmp_data-2.7.0/tests/integration/cassette_contracts.json +85 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/conftest.py +9 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_company.py +19 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_intelligence.py +123 -4
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_lc.py +2 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/conftest.py +5 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_config.py +15 -3
- fmp_data-2.7.0/tests/unit/lc/test_embedding.py +207 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_endpoint_method_coverage.py +7 -11
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_method_dispatch.py +78 -7
- fmp_data-2.7.0/tests/unit/lc/test_package_init.py +915 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_tool_schema.py +4 -4
- fmp_data-2.7.0/tests/unit/lc/test_validation.py +631 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_arg_model_deprecation.py +1 -1
- fmp_data-2.7.0/tests/unit/test_artifact_action_pins.py +46 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_async_clients.py +213 -6
- fmp_data-2.7.0/tests/unit/test_bandit_skips.py +59 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_base.py +975 -8
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_base_async.py +99 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_base_coverage.py +11 -4
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_batch.py +158 -11
- fmp_data-2.7.0/tests/unit/test_bulk_bytes.py +330 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_cassette_contracts.py +78 -1
- fmp_data-2.7.0/tests/unit/test_checkout_credentials.py +82 -0
- fmp_data-2.7.0/tests/unit/test_ci_quality_gates.py +125 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_client.py +6 -6
- fmp_data-2.7.0/tests/unit/test_closed_vocabularies.py +546 -0
- fmp_data-2.7.0/tests/unit/test_codeql_workflow.py +50 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_company.py +385 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_company_coverage.py +158 -15
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_config.py +34 -6
- fmp_data-2.7.0/tests/unit/test_config_secret_serialization.py +276 -0
- fmp_data-2.7.0/tests/unit/test_dependabot_action_groups.py +17 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_deprecated_endpoint_flags.py +2 -2
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_docs_tools_sync.py +24 -1
- fmp_data-2.7.0/tests/unit/test_e2e_harness.py +38 -0
- fmp_data-2.7.0/tests/unit/test_e2e_sweep.py +221 -0
- fmp_data-2.7.0/tests/unit/test_example_json_fences.py +33 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_exceptions.py +42 -0
- fmp_data-2.7.0/tests/unit/test_export_dotenv.py +110 -0
- fmp_data-2.7.0/tests/unit/test_extras_coverage_gate.py +178 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_fundamental.py +132 -6
- fmp_data-2.7.0/tests/unit/test_hosted_mcp_docs.py +65 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_institutional.py +15 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_intelligence.py +503 -2
- fmp_data-2.7.0/tests/unit/test_list_unwrap.py +555 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_logger.py +418 -13
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_market.py +20 -1
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_mcp.py +137 -20
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_mcp_cli.py +155 -0
- fmp_data-2.7.0/tests/unit/test_mcp_config_perms.py +42 -0
- fmp_data-2.7.0/tests/unit/test_mcp_setup.py +1195 -0
- fmp_data-2.7.0/tests/unit/test_mcp_utils.py +1540 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_models.py +78 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_param_required_consistency.py +27 -0
- fmp_data-2.7.0/tests/unit/test_path_params.py +46 -0
- fmp_data-2.7.0/tests/unit/test_publish_pins.py +60 -0
- fmp_data-2.7.0/tests/unit/test_redaction_rules.py +221 -0
- fmp_data-2.7.0/tests/unit/test_redis_backend.py +461 -0
- fmp_data-2.7.0/tests/unit/test_release_tag_push.py +123 -0
- fmp_data-2.7.0/tests/unit/test_secret_scan_ci.py +21 -0
- fmp_data-2.7.0/tests/unit/test_security_audit_pins.py +29 -0
- fmp_data-2.7.0/tests/unit/test_setup_uv_pin.py +37 -0
- fmp_data-2.7.0/tests/unit/test_tag_ancestry_guard.py +71 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_vcr_sanitization.py +17 -6
- fmp_data-2.7.0/tests/unit/test_workflow_permission_isolation.py +200 -0
- fmp_data-2.6.0/fmp_data/batch/_csv_utils.py +0 -121
- fmp_data-2.6.0/fmp_data/mcp/utils.py +0 -434
- fmp_data-2.6.0/tests/unit/lc/test_embedding.py +0 -99
- {fmp_data-2.6.0 → fmp_data-2.7.0}/LICENSE +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/NOTICE +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/alternative/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/alternative/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/async_client.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/batch/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/batch/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/cache/base.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/cache/memory.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/client.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/economics/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/economics/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/economics/schema.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/fundamental/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/fundamental/schema.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/helpers.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/index/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/index/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/institutional/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/institutional/schema.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/intelligence/schema.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/investment/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/investment/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/investment/schema.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/mapping.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/lc/utils.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/hints.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/market/schema.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/__main__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/_compat.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/discovery.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/mcp/tool_loader.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/py.typed +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/sec/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/sec/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/technical/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/technical/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/transcripts/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/fmp_data/transcripts/models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/e2e/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/examples/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/examples/test_examples_smoke.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/base.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_alternative.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_batch.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_economics.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_fundamental.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_index.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_institutional.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_investment.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_market.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_sec.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_technical.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/integration/test_transcripts.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/__init__.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/conftest.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_deprecated_endpoints.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_endpoint_based_rules.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_imports.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_mapping.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_models.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_utils.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_validation_registry.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/lc/test_vector_store.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_alternative.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_alternative_coverage.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_cache_backends.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_cache_integration.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_cache_ttl_override_keys.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_catalog_registration.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_datetime_shadowing.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_deprecated_methods_warn.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_docs_endpoints_sync.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_economics.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_endpoint_registry.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_helpers.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_hint_consolidation.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_imports.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_index.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_investment.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_mcp_entry_point_coherence.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_rate_limit.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_rate_limit_async.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_rate_limit_coverage.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_sec.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_technical.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_technical_coverage.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_tool_binding.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_transcripts.py +0 -0
- {fmp_data-2.6.0 → fmp_data-2.7.0}/tests/unit/test_vector_store_error_contract.py +0 -0
|
@@ -27,11 +27,16 @@ env/
|
|
|
27
27
|
venv/
|
|
28
28
|
ENV/
|
|
29
29
|
|
|
30
|
-
# Lock files
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
30
|
+
# Lock files — deliberately not committed (#273).
|
|
31
|
+
# fmp-data ships as a library, so the compatibility contract is the version
|
|
32
|
+
# floors in pyproject.toml; installers resolve against those and never read a
|
|
33
|
+
# committed lock. Freezing one here would only pin CI, at the cost of a ~1MB
|
|
34
|
+
# blob and a multi-thousand-line diff on every dependency bump.
|
|
35
|
+
# Drift is caught rather than frozen: `nox -s security` exports the live
|
|
36
|
+
# extras graph and audits it with `pip-audit --strict`, and the Actions used
|
|
37
|
+
# by CI/publish are SHA-pinned (#252 FMP-SEC-002/008). See CONTRIBUTING.md
|
|
38
|
+
# "Lock file policy".
|
|
39
|
+
# Generate locally with: uv sync
|
|
35
40
|
uv.lock
|
|
36
41
|
poetry.lock
|
|
37
42
|
|
|
@@ -60,6 +65,8 @@ cover/
|
|
|
60
65
|
|
|
61
66
|
# VCR cassettes (large recorded API responses, regenerated locally)
|
|
62
67
|
tests/integration/vcr_cassettes/
|
|
68
|
+
tests/e2e/vcr_cassettes/
|
|
69
|
+
tests/e2e/reports/
|
|
63
70
|
|
|
64
71
|
# Build
|
|
65
72
|
*.manifest
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: fmp-data
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
4
|
Summary: Python client for the Financial Modeling Prep API
|
|
5
5
|
Project-URL: Homepage, https://github.com/MehdiZare/fmp-data
|
|
6
6
|
Project-URL: Repository, https://github.com/MehdiZare/fmp-data
|
|
@@ -66,6 +66,7 @@ Requires-Dist: tiktoken>=0.13.0; extra == 'langchain'
|
|
|
66
66
|
Provides-Extra: mcp
|
|
67
67
|
Requires-Dist: mcp[cli]>=2.0.0; extra == 'mcp'
|
|
68
68
|
Requires-Dist: pyyaml>=6.0.3; extra == 'mcp'
|
|
69
|
+
Requires-Dist: tomli>=2.0.1; (python_version < '3.11') and extra == 'mcp'
|
|
69
70
|
Description-Content-Type: text/markdown
|
|
70
71
|
|
|
71
72
|
# FMP Data Client
|
|
@@ -102,7 +103,7 @@ This project uses UV as the primary package management tool for several key bene
|
|
|
102
103
|
- Automatic retries with exponential backoff
|
|
103
104
|
- 85%+ test coverage with comprehensive test suite
|
|
104
105
|
- VCR cassette-backed integration tests with 100% endpoint contract validation
|
|
105
|
-
- Automated
|
|
106
|
+
- Automated secret scanning of the committed tree (pre-commit + CI)
|
|
106
107
|
- Secure API key handling
|
|
107
108
|
- 100% coverage of FMP stable endpoints
|
|
108
109
|
- Detailed error messages
|
|
@@ -199,7 +200,15 @@ export FMP_CACHE_REDIS_URL=redis://localhost:6379/0
|
|
|
199
200
|
|
|
200
201
|
## MCP Server (Claude Desktop Integration)
|
|
201
202
|
|
|
202
|
-
|
|
203
|
+
`fmp-mcp` is this package's **local** Model Context Protocol server. It exposes
|
|
204
|
+
our typed client as stdio tools for Claude Desktop and other MCP hosts.
|
|
205
|
+
|
|
206
|
+
FMP also ships a **hosted** MCP server at
|
|
207
|
+
`https://financialmodelingprep.com/mcp` (28 dataset-oriented tools, API key in
|
|
208
|
+
the URL). That is a different product. Use hosted MCP for a zero-install
|
|
209
|
+
agent connector; use `fmp-mcp` for the broader MCP tool catalog, manifests,
|
|
210
|
+
and typed local control. Comparison and coverage matrix:
|
|
211
|
+
[docs/mcp/hosted.md](docs/mcp/hosted.md).
|
|
203
212
|
|
|
204
213
|
### Quick Setup for Claude Desktop
|
|
205
214
|
|
|
@@ -246,14 +255,11 @@ Full tool list: [docs/mcp/tools.md](https://github.com/MehdiZare/fmp-data/blob/m
|
|
|
246
255
|
export FMP_API_KEY=your_api_key_here
|
|
247
256
|
export FMP_MCP_MANIFEST=/path/to/custom/manifest.py
|
|
248
257
|
|
|
249
|
-
# Custom manifest example (manifest.
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
"fundamental.income_statement",
|
|
255
|
-
"fundamental.balance_sheet"
|
|
256
|
-
]
|
|
258
|
+
# Custom manifest example (manifest.json — preferred)
|
|
259
|
+
# { "tools": ["company.profile", "company.quote"] }
|
|
260
|
+
#
|
|
261
|
+
# Legacy Python is parsed as data, not executed:
|
|
262
|
+
# TOOLS = ["company.profile", "company.quote"]
|
|
257
263
|
```
|
|
258
264
|
|
|
259
265
|
### Integration with AI Assistants
|
|
@@ -363,8 +369,10 @@ client = FMPDataClient(config=config)
|
|
|
363
369
|
|
|
364
370
|
# Create vector store using the config
|
|
365
371
|
vector_store = create_vector_store(
|
|
366
|
-
|
|
367
|
-
|
|
372
|
+
# Credential fields are `SecretStr`, so `model_dump()` cannot leak them.
|
|
373
|
+
# Unwrap with `.get_secret_value()` wherever a plain string is required.
|
|
374
|
+
fmp_api_key=config.api_key.get_secret_value(), # pragma: allowlist secret
|
|
375
|
+
openai_api_key=config.embedding_api_key.get_secret_value(), # pragma: allowlist secret
|
|
368
376
|
cache_dir=config.vector_store_path,
|
|
369
377
|
embedding_provider=config.embedding_provider,
|
|
370
378
|
embedding_model=config.embedding_model,
|
|
@@ -527,13 +535,14 @@ with FMPDataClient.from_env() as client:
|
|
|
527
535
|
|
|
528
536
|
### 2. Financial Statements
|
|
529
537
|
```python
|
|
530
|
-
from fmp_data import FMPDataClient
|
|
538
|
+
from fmp_data import FMPDataClient, Period
|
|
531
539
|
|
|
532
540
|
with FMPDataClient.from_env() as client:
|
|
533
541
|
# Get income statements
|
|
542
|
+
period: Period = "quarter"
|
|
534
543
|
income_stmt = client.fundamental.get_income_statement(
|
|
535
544
|
"AAPL",
|
|
536
|
-
period=
|
|
545
|
+
period=period,
|
|
537
546
|
limit=4,
|
|
538
547
|
)
|
|
539
548
|
|
|
@@ -546,6 +555,8 @@ with FMPDataClient.from_env() as client:
|
|
|
546
555
|
|
|
547
556
|
### 3. Market Data
|
|
548
557
|
```python
|
|
558
|
+
from datetime import date
|
|
559
|
+
|
|
549
560
|
from fmp_data import FMPDataClient
|
|
550
561
|
|
|
551
562
|
with FMPDataClient.from_env() as client:
|
|
@@ -558,25 +569,27 @@ with FMPDataClient.from_env() as client:
|
|
|
558
569
|
)
|
|
559
570
|
|
|
560
571
|
# Get intraday prices
|
|
561
|
-
|
|
572
|
+
from fmp_data import Interval
|
|
573
|
+
|
|
574
|
+
interval: Interval = "5min"
|
|
575
|
+
intraday = client.company.get_intraday_prices("TSLA", interval=interval)
|
|
562
576
|
```
|
|
563
577
|
|
|
564
578
|
### 4. Technical Indicators
|
|
565
579
|
```python
|
|
566
|
-
from fmp_data import FMPDataClient
|
|
567
|
-
from datetime import date
|
|
580
|
+
from fmp_data import FMPDataClient, TechnicalInterval, Timeframe
|
|
568
581
|
|
|
569
582
|
with FMPDataClient.from_env() as client:
|
|
570
583
|
# Simple Moving Average
|
|
571
|
-
|
|
584
|
+
timeframe: Timeframe = "1day"
|
|
585
|
+
sma = client.technical.get_sma("AAPL", period_length=20, timeframe=timeframe)
|
|
586
|
+
|
|
587
|
+
# leftover interval aliases map onto Timeframe (daily→1day)
|
|
588
|
+
interval: TechnicalInterval = "daily"
|
|
589
|
+
sma_daily = client.technical.get_sma("AAPL", period_length=20, interval=interval)
|
|
572
590
|
|
|
573
591
|
# RSI (Relative Strength Index)
|
|
574
592
|
rsi = client.technical.get_rsi("AAPL", period_length=14, timeframe="1day")
|
|
575
|
-
|
|
576
|
-
# MACD
|
|
577
|
-
macd = client.technical.get_macd(
|
|
578
|
-
"AAPL", fast_period=12, slow_period=26, signal_period=9
|
|
579
|
-
)
|
|
580
593
|
```
|
|
581
594
|
|
|
582
595
|
### 5. Alternative Data
|
|
@@ -789,6 +802,8 @@ The library provides a comprehensive exception hierarchy for robust error handli
|
|
|
789
802
|
from fmp_data import FMPDataClient
|
|
790
803
|
from fmp_data.exceptions import (
|
|
791
804
|
FMPError, # Base exception for all FMP errors
|
|
805
|
+
FMPTimeoutError, # HTTP request timed out
|
|
806
|
+
FMPNetworkError, # Transport / leftover RequestError
|
|
792
807
|
RateLimitError, # API rate limit exceeded
|
|
793
808
|
AuthenticationError, # Invalid or missing API key
|
|
794
809
|
ValidationError, # Invalid request parameters
|
|
@@ -32,7 +32,7 @@ This project uses UV as the primary package management tool for several key bene
|
|
|
32
32
|
- Automatic retries with exponential backoff
|
|
33
33
|
- 85%+ test coverage with comprehensive test suite
|
|
34
34
|
- VCR cassette-backed integration tests with 100% endpoint contract validation
|
|
35
|
-
- Automated
|
|
35
|
+
- Automated secret scanning of the committed tree (pre-commit + CI)
|
|
36
36
|
- Secure API key handling
|
|
37
37
|
- 100% coverage of FMP stable endpoints
|
|
38
38
|
- Detailed error messages
|
|
@@ -129,7 +129,15 @@ export FMP_CACHE_REDIS_URL=redis://localhost:6379/0
|
|
|
129
129
|
|
|
130
130
|
## MCP Server (Claude Desktop Integration)
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
`fmp-mcp` is this package's **local** Model Context Protocol server. It exposes
|
|
133
|
+
our typed client as stdio tools for Claude Desktop and other MCP hosts.
|
|
134
|
+
|
|
135
|
+
FMP also ships a **hosted** MCP server at
|
|
136
|
+
`https://financialmodelingprep.com/mcp` (28 dataset-oriented tools, API key in
|
|
137
|
+
the URL). That is a different product. Use hosted MCP for a zero-install
|
|
138
|
+
agent connector; use `fmp-mcp` for the broader MCP tool catalog, manifests,
|
|
139
|
+
and typed local control. Comparison and coverage matrix:
|
|
140
|
+
[docs/mcp/hosted.md](docs/mcp/hosted.md).
|
|
133
141
|
|
|
134
142
|
### Quick Setup for Claude Desktop
|
|
135
143
|
|
|
@@ -176,14 +184,11 @@ Full tool list: [docs/mcp/tools.md](https://github.com/MehdiZare/fmp-data/blob/m
|
|
|
176
184
|
export FMP_API_KEY=your_api_key_here
|
|
177
185
|
export FMP_MCP_MANIFEST=/path/to/custom/manifest.py
|
|
178
186
|
|
|
179
|
-
# Custom manifest example (manifest.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"fundamental.income_statement",
|
|
185
|
-
"fundamental.balance_sheet"
|
|
186
|
-
]
|
|
187
|
+
# Custom manifest example (manifest.json — preferred)
|
|
188
|
+
# { "tools": ["company.profile", "company.quote"] }
|
|
189
|
+
#
|
|
190
|
+
# Legacy Python is parsed as data, not executed:
|
|
191
|
+
# TOOLS = ["company.profile", "company.quote"]
|
|
187
192
|
```
|
|
188
193
|
|
|
189
194
|
### Integration with AI Assistants
|
|
@@ -293,8 +298,10 @@ client = FMPDataClient(config=config)
|
|
|
293
298
|
|
|
294
299
|
# Create vector store using the config
|
|
295
300
|
vector_store = create_vector_store(
|
|
296
|
-
|
|
297
|
-
|
|
301
|
+
# Credential fields are `SecretStr`, so `model_dump()` cannot leak them.
|
|
302
|
+
# Unwrap with `.get_secret_value()` wherever a plain string is required.
|
|
303
|
+
fmp_api_key=config.api_key.get_secret_value(), # pragma: allowlist secret
|
|
304
|
+
openai_api_key=config.embedding_api_key.get_secret_value(), # pragma: allowlist secret
|
|
298
305
|
cache_dir=config.vector_store_path,
|
|
299
306
|
embedding_provider=config.embedding_provider,
|
|
300
307
|
embedding_model=config.embedding_model,
|
|
@@ -457,13 +464,14 @@ with FMPDataClient.from_env() as client:
|
|
|
457
464
|
|
|
458
465
|
### 2. Financial Statements
|
|
459
466
|
```python
|
|
460
|
-
from fmp_data import FMPDataClient
|
|
467
|
+
from fmp_data import FMPDataClient, Period
|
|
461
468
|
|
|
462
469
|
with FMPDataClient.from_env() as client:
|
|
463
470
|
# Get income statements
|
|
471
|
+
period: Period = "quarter"
|
|
464
472
|
income_stmt = client.fundamental.get_income_statement(
|
|
465
473
|
"AAPL",
|
|
466
|
-
period=
|
|
474
|
+
period=period,
|
|
467
475
|
limit=4,
|
|
468
476
|
)
|
|
469
477
|
|
|
@@ -476,6 +484,8 @@ with FMPDataClient.from_env() as client:
|
|
|
476
484
|
|
|
477
485
|
### 3. Market Data
|
|
478
486
|
```python
|
|
487
|
+
from datetime import date
|
|
488
|
+
|
|
479
489
|
from fmp_data import FMPDataClient
|
|
480
490
|
|
|
481
491
|
with FMPDataClient.from_env() as client:
|
|
@@ -488,25 +498,27 @@ with FMPDataClient.from_env() as client:
|
|
|
488
498
|
)
|
|
489
499
|
|
|
490
500
|
# Get intraday prices
|
|
491
|
-
|
|
501
|
+
from fmp_data import Interval
|
|
502
|
+
|
|
503
|
+
interval: Interval = "5min"
|
|
504
|
+
intraday = client.company.get_intraday_prices("TSLA", interval=interval)
|
|
492
505
|
```
|
|
493
506
|
|
|
494
507
|
### 4. Technical Indicators
|
|
495
508
|
```python
|
|
496
|
-
from fmp_data import FMPDataClient
|
|
497
|
-
from datetime import date
|
|
509
|
+
from fmp_data import FMPDataClient, TechnicalInterval, Timeframe
|
|
498
510
|
|
|
499
511
|
with FMPDataClient.from_env() as client:
|
|
500
512
|
# Simple Moving Average
|
|
501
|
-
|
|
513
|
+
timeframe: Timeframe = "1day"
|
|
514
|
+
sma = client.technical.get_sma("AAPL", period_length=20, timeframe=timeframe)
|
|
515
|
+
|
|
516
|
+
# leftover interval aliases map onto Timeframe (daily→1day)
|
|
517
|
+
interval: TechnicalInterval = "daily"
|
|
518
|
+
sma_daily = client.technical.get_sma("AAPL", period_length=20, interval=interval)
|
|
502
519
|
|
|
503
520
|
# RSI (Relative Strength Index)
|
|
504
521
|
rsi = client.technical.get_rsi("AAPL", period_length=14, timeframe="1day")
|
|
505
|
-
|
|
506
|
-
# MACD
|
|
507
|
-
macd = client.technical.get_macd(
|
|
508
|
-
"AAPL", fast_period=12, slow_period=26, signal_period=9
|
|
509
|
-
)
|
|
510
522
|
```
|
|
511
523
|
|
|
512
524
|
### 5. Alternative Data
|
|
@@ -719,6 +731,8 @@ The library provides a comprehensive exception hierarchy for robust error handli
|
|
|
719
731
|
from fmp_data import FMPDataClient
|
|
720
732
|
from fmp_data.exceptions import (
|
|
721
733
|
FMPError, # Base exception for all FMP errors
|
|
734
|
+
FMPTimeoutError, # HTTP request timed out
|
|
735
|
+
FMPNetworkError, # Transport / leftover RequestError
|
|
722
736
|
RateLimitError, # API rate limit exceeded
|
|
723
737
|
AuthenticationError, # Invalid or missing API key
|
|
724
738
|
ValidationError, # Invalid request parameters
|
|
@@ -31,11 +31,22 @@ from fmp_data.exceptions import (
|
|
|
31
31
|
AuthenticationError,
|
|
32
32
|
ConfigError,
|
|
33
33
|
FMPError,
|
|
34
|
+
FMPNetworkError,
|
|
35
|
+
FMPTimeoutError,
|
|
34
36
|
RateLimitError,
|
|
35
37
|
ValidationError,
|
|
36
38
|
VectorStoreCreationError,
|
|
37
39
|
)
|
|
38
40
|
from fmp_data.logger import FMPLogger
|
|
41
|
+
from fmp_data.schema import (
|
|
42
|
+
Interval,
|
|
43
|
+
Period,
|
|
44
|
+
PeriodAnnualQuarter,
|
|
45
|
+
PeriodFiscal,
|
|
46
|
+
Structure,
|
|
47
|
+
TechnicalInterval,
|
|
48
|
+
Timeframe,
|
|
49
|
+
)
|
|
39
50
|
|
|
40
51
|
# Version handling - generated by hatch-vcs
|
|
41
52
|
try:
|
|
@@ -56,10 +67,19 @@ __all__ = [
|
|
|
56
67
|
"FMPDataClient",
|
|
57
68
|
"FMPError",
|
|
58
69
|
"FMPLogger",
|
|
70
|
+
"FMPNetworkError",
|
|
71
|
+
"FMPTimeoutError",
|
|
72
|
+
"Interval",
|
|
59
73
|
"LogHandlerConfig",
|
|
60
74
|
"LoggingConfig",
|
|
75
|
+
"Period",
|
|
76
|
+
"PeriodAnnualQuarter",
|
|
77
|
+
"PeriodFiscal",
|
|
61
78
|
"RateLimitConfig",
|
|
62
79
|
"RateLimitError",
|
|
80
|
+
"Structure",
|
|
81
|
+
"TechnicalInterval",
|
|
82
|
+
"Timeframe",
|
|
63
83
|
"ValidationError",
|
|
64
84
|
"VectorStoreCreationError",
|
|
65
85
|
"__version__",
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Shared rules for hiding credentials in display strings (#252, #316).
|
|
2
|
+
|
|
3
|
+
Two jobs live here:
|
|
4
|
+
|
|
5
|
+
1. **Key-name walk** (``is_secret_key`` / ``redact_value``): ``ClientConfig.__str__``
|
|
6
|
+
and ``EmbeddingConfig.__repr__`` need the same judgement about what looks
|
|
7
|
+
like a credential in a structured mapping.
|
|
8
|
+
2. **Free-form text**: query/assignment/encoded patterns
|
|
9
|
+
(``redact_credential_patterns``) are shared by HTTP error bodies and the
|
|
10
|
+
setup wizard. Wizard console also runs ``redact_key_shaped_tokens``
|
|
11
|
+
(sk-/32-char heuristics). Those stay off the error-body path — they
|
|
12
|
+
blank request ids. Prompts use ``redact_held_secret``.
|
|
13
|
+
|
|
14
|
+
This is a *display* safeguard, not an access control. Values are still fully
|
|
15
|
+
available on the model; only the rendered text is masked.
|
|
16
|
+
|
|
17
|
+
CodeQL ``py/clear-text-logging-sensitive-data`` treats ``print`` / stdout as
|
|
18
|
+
a logging sink. Sinks may call :func:`redact_credential_patterns` (it never
|
|
19
|
+
takes the live secret). They must not call :func:`redact_held_secret` — that
|
|
20
|
+
API is for ``input`` / ``getpass`` prompts only.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import re
|
|
26
|
+
from typing import Any
|
|
27
|
+
|
|
28
|
+
# Matched against ``_``/``-`` separated parts of a key name, so ``api_key``,
|
|
29
|
+
# ``client-secret`` and ``refreshToken`` are caught but ``keyboard`` is not.
|
|
30
|
+
_SECRET_KEY_TOKENS = frozenset(
|
|
31
|
+
{
|
|
32
|
+
"key",
|
|
33
|
+
"apikey",
|
|
34
|
+
"token",
|
|
35
|
+
"secret",
|
|
36
|
+
"password",
|
|
37
|
+
"passwd",
|
|
38
|
+
"pwd",
|
|
39
|
+
"passphrase",
|
|
40
|
+
"credential",
|
|
41
|
+
"credentials",
|
|
42
|
+
"authorization",
|
|
43
|
+
"auth",
|
|
44
|
+
"bearer",
|
|
45
|
+
"signature",
|
|
46
|
+
"private",
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
_MASK = "***"
|
|
51
|
+
|
|
52
|
+
# Deeper structures are elided rather than walked. Config is not expected to
|
|
53
|
+
# nest this far, and an unbounded walk on a cyclic or adversarial structure is
|
|
54
|
+
# not worth the risk in a `__str__`.
|
|
55
|
+
_MAX_DEPTH = 6
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _split_key(key: str) -> list[str]:
|
|
59
|
+
"""Split a key name into comparable parts, including camelCase.
|
|
60
|
+
|
|
61
|
+
The boundary is a *lower-to-upper* transition, not any capital: splitting
|
|
62
|
+
on every capital shreds an all-caps name, so ``API_KEY`` would become
|
|
63
|
+
``["a", "p", "i", ...]`` and match nothing.
|
|
64
|
+
"""
|
|
65
|
+
normalized = key.replace("-", "_")
|
|
66
|
+
parts: list[str] = []
|
|
67
|
+
for chunk in normalized.split("_"):
|
|
68
|
+
# `refreshToken` -> ["refresh", "Token"]; `API` stays `["API"]`
|
|
69
|
+
current = ""
|
|
70
|
+
for char in chunk:
|
|
71
|
+
if char.isupper() and current and not current[-1].isupper():
|
|
72
|
+
parts.append(current)
|
|
73
|
+
current = char
|
|
74
|
+
else:
|
|
75
|
+
current += char
|
|
76
|
+
if current:
|
|
77
|
+
parts.append(current)
|
|
78
|
+
return [part.lower() for part in parts if part]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def is_secret_key(key: str) -> bool:
|
|
82
|
+
"""True when a key name looks like it holds a credential."""
|
|
83
|
+
return any(part in _SECRET_KEY_TOKENS for part in _split_key(key))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def redact_value(value: Any, depth: int = 0) -> Any:
|
|
87
|
+
"""Copy a value with secret-shaped entries inside containers replaced.
|
|
88
|
+
|
|
89
|
+
Recursion matters: credentials show up in *nested* untyped bags --
|
|
90
|
+
``OpenAIEmbeddings`` takes ``default_headers={"Authorization": ...}``, and
|
|
91
|
+
``LogHandlerConfig.handler_kwargs`` is a bare ``dict[str, Any]`` handed
|
|
92
|
+
straight to a logging handler. A top-level-only scan copies those by
|
|
93
|
+
reference and prints the secret verbatim (#273).
|
|
94
|
+
"""
|
|
95
|
+
if depth >= _MAX_DEPTH:
|
|
96
|
+
return "..."
|
|
97
|
+
if isinstance(value, dict):
|
|
98
|
+
return {
|
|
99
|
+
key: (
|
|
100
|
+
_MASK
|
|
101
|
+
if isinstance(key, str) and is_secret_key(key)
|
|
102
|
+
else redact_value(item, depth + 1)
|
|
103
|
+
)
|
|
104
|
+
for key, item in value.items()
|
|
105
|
+
}
|
|
106
|
+
if isinstance(value, list | tuple):
|
|
107
|
+
return type(value)(redact_value(item, depth + 1) for item in value)
|
|
108
|
+
if isinstance(value, set):
|
|
109
|
+
return {redact_value(item, depth + 1) for item in value}
|
|
110
|
+
return value
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def redact_mapping(data: dict[str, Any]) -> dict[str, Any]:
|
|
114
|
+
"""Copy a mapping with secret-shaped keys masked, recursively."""
|
|
115
|
+
return {
|
|
116
|
+
key: (_MASK if is_secret_key(key) else redact_value(value))
|
|
117
|
+
for key, value in data.items()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# --- Free-form text -------------------------------------------------------
|
|
122
|
+
# Pattern-only. Never take the live secret as an argument. Safe for
|
|
123
|
+
# logging sinks / stdout (CodeQL py/clear-text-logging-sensitive-data).
|
|
124
|
+
# ``api[_-]?key`` covers ``apikey``, ``api_key``, and hyphenated ``api-key``.
|
|
125
|
+
_URL_CREDENTIAL_RE = re.compile(
|
|
126
|
+
r"([?&](?:api[_-]?key|token|secret)=)[^&\s]+",
|
|
127
|
+
re.IGNORECASE,
|
|
128
|
+
)
|
|
129
|
+
_URL_APIKEY_RE = re.compile(r"([?&]apikey=)[^&\s]+", re.IGNORECASE)
|
|
130
|
+
# Prefixed ``*_API_KEY=`` / hyphenated ``*-API-KEY=`` must match
|
|
131
|
+
# (#330, #339). Only the wizard's instruction value is skipped so
|
|
132
|
+
# ``export FMP_API_KEY="[YOUR_API_KEY]"`` stays readable.
|
|
133
|
+
_ASSIGNMENT_RE = re.compile(
|
|
134
|
+
r"([\"']?(?<![A-Za-z0-9])(?:[A-Za-z0-9]+[_-])*api[_-]?key[\"']?\s*[=:]\s*[\"']?)"
|
|
135
|
+
r"([^&\s\"'<>]+)([\"']?)",
|
|
136
|
+
re.IGNORECASE,
|
|
137
|
+
)
|
|
138
|
+
_PLACEHOLDER_ASSIGNMENT_VALUE = re.compile(
|
|
139
|
+
r"^\[YOUR_API_KEY\]$",
|
|
140
|
+
re.IGNORECASE,
|
|
141
|
+
)
|
|
142
|
+
_ENCODED_RE = re.compile(r"(apikey%3[Dd])([^&\s\"'<>]+)", re.IGNORECASE)
|
|
143
|
+
# Wizard-console only. ``[a-zA-Z0-9]{32,}`` matches request ids; do not
|
|
144
|
+
# run these on HTTP error bodies (``base._redact_api_keys``).
|
|
145
|
+
_KEY_SHAPED_RES = (
|
|
146
|
+
re.compile(r"\b(?:sk-|pk_)[a-zA-Z0-9_-]{8,}\b"),
|
|
147
|
+
re.compile(r"\bapi_key=[a-zA-Z0-9_-]{8,}(?=\s|:|;|$)"),
|
|
148
|
+
re.compile(r"\b[a-zA-Z0-9]{32,}\b"),
|
|
149
|
+
re.compile(r"[a-fA-F0-9]{40,}"),
|
|
150
|
+
)
|
|
151
|
+
_TEXT_MASK = "[REDACTED]"
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _redact_assignment(match: re.Match[str]) -> str:
|
|
155
|
+
"""Redact an assignment unless the value is ``[YOUR_API_KEY]``."""
|
|
156
|
+
value = match.group(2)
|
|
157
|
+
if _PLACEHOLDER_ASSIGNMENT_VALUE.match(value):
|
|
158
|
+
return match.group(0)
|
|
159
|
+
return f"{match.group(1)}{_TEXT_MASK}{match.group(3)}"
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def redact_credential_patterns(text: str) -> str:
|
|
163
|
+
"""Redact query/assignment/encoded credentials without the live secret.
|
|
164
|
+
|
|
165
|
+
Safe for logging sinks, stdout, and HTTP error bodies. Does not apply
|
|
166
|
+
wizard key-shaped heuristics (those blank request ids). Do not pass
|
|
167
|
+
the held secret; use :func:`redact_held_secret` at prompt sites only.
|
|
168
|
+
"""
|
|
169
|
+
result = _URL_CREDENTIAL_RE.sub(rf"\1{_TEXT_MASK}", text)
|
|
170
|
+
result = _URL_APIKEY_RE.sub(rf"\1{_TEXT_MASK}", result)
|
|
171
|
+
result = _ASSIGNMENT_RE.sub(_redact_assignment, result)
|
|
172
|
+
return _ENCODED_RE.sub(rf"\1{_TEXT_MASK}", result)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def redact_key_shaped_tokens(text: str) -> str:
|
|
176
|
+
"""Redact sk-/pk_/32-char tokens. Wizard console only.
|
|
177
|
+
|
|
178
|
+
Not for HTTP error bodies. Pair with :func:`redact_credential_patterns`
|
|
179
|
+
at console sinks that must also catch keys the wizard never held.
|
|
180
|
+
"""
|
|
181
|
+
result = text
|
|
182
|
+
for pattern in _KEY_SHAPED_RES:
|
|
183
|
+
result = pattern.sub(_TEXT_MASK, result)
|
|
184
|
+
return result
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def redact_held_secret(text: str, secret: str) -> str:
|
|
188
|
+
"""Exact-replace a caller-held secret. Prompts / getpass only.
|
|
189
|
+
|
|
190
|
+
Never feed the result to a logging sink or stdout writer that CodeQL
|
|
191
|
+
treats as clear-text logging (``py/clear-text-logging-sensitive-data``).
|
|
192
|
+
"""
|
|
193
|
+
if not secret:
|
|
194
|
+
return text
|
|
195
|
+
return text.replace(secret, _TEXT_MASK)
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.
|
|
22
|
-
__version_tuple__ = version_tuple = (2,
|
|
21
|
+
__version__ = version = '2.7.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 7, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|