Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - Warn if inexistent kwargs #6236

Merged
merged 6 commits into from
Mar 20, 2024
Merged

Conversation

montezdesousa
Copy link
Contributor

@montezdesousa montezdesousa commented Mar 18, 2024

  1. Why?

    • Inexistent kwargs are ignored silently
  2. What?

    • Move kwargs filter from Query.py to CommandRunner.validate_kwargs method
    • We validate all the arguments here and warn if any does not exists
    • Move warnings context manager outside the command execution to allow suppressing validate_kwarg warnings and to collect them into OBBject
  3. Impact

    • Feature just adds a warning if kwarg does not exist, remaining stays the same
  4. Testing Done:

    • Equity + Technical + core integration tests run to get some variability

    • Toggle obb.user.preferences.show_warnings to check if the warning is supressed

# kwargs don't exist
>>> obb.equity.price.historical("AAPL", foo="test", bar="test")
        OBBject
        
        id: 065f985a-e277-7d73-8000-00e1f8499b99
        results: [{'date': datetime.date(2023, 3, 20), 'open': 155.07, 'high': 157.82, 'low...
        provider: fmp
        warnings: [{'category': 'OpenBBWarning', 'message': "Parameter 'foo' not found."}, ...
        chart: None
        extra: {'metadata': {'arguments': {'provider_choices': {'provider': 'fmp'}, 'standa...

# kwarg exists but in a different provider
>>> obb.equity.price.historical("AAPL", prepost=True, provider="fmp")
        OBBject
        
        id: 065f9861-3d20-7557-8000-b302347c6c81
        results: [{'date': datetime.date(2023, 3, 20), 'open': 155.07, 'high': 157.82, 'low...
        provider: fmp
        warnings: [{'category': 'OpenBBWarning', 'message': "Parameter 'prepost' is not sup...
        chart: None
        extra: {'metadata': {'arguments': {'provider_choices': {'provider': 'fmp'}, 'standa..

@github-actions github-actions bot added bug Fix bug platform OpenBB Platform v4 PRs for v4 labels Mar 18, 2024
@montezdesousa montezdesousa marked this pull request as ready for review March 19, 2024 12:37
@montezdesousa montezdesousa changed the title feat: warn if wrong kwargs [Feature] - warn if inexistent kwargs Mar 19, 2024
@montezdesousa montezdesousa changed the title [Feature] - warn if inexistent kwargs [Feature] - Warn if inexistent kwargs Mar 19, 2024
@montezdesousa montezdesousa added the do not merge Label to prevent pull request merge label Mar 19, 2024
@montezdesousa montezdesousa removed the do not merge Label to prevent pull request merge label Mar 20, 2024
@montezdesousa montezdesousa added this pull request to the merge queue Mar 20, 2024
Merged via the queue into develop with commit 7f4007a Mar 20, 2024
10 of 11 checks passed
@IgorWounds IgorWounds deleted the bugfix/warn_kwargs branch March 20, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fix bug platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants