ryansurf / cli-surf

Get surf and ocean data from the command line interface
MIT License
18 stars 30 forks source link

Json fix #85

Closed ryansurf closed 3 months ago

ryansurf commented 3 months ago

Hello @K-dash !

This PR mostly cleans up helper.py. Addresses https://github.com/ryansurf/cli-surf/issues/84

Changes

src/api.py

Mostly organizing code. forecast() now returns a dictionary, not several nested lists, for reusability

src/helper.py

src/test_api.py

test_forecast() was failing because of the dictionary now being returned from the forecast. Fixed this

src/test_helper.py

A new unit test was added to test the json argument. Prior to this, the json argument was causing an error and we were non-the-wiser because our tests didn't catch this!

Summary by Sourcery

Refactor helper functions to use mappings for setting and printing argument values, update forecast data handling to use dictionaries, and enhance test coverage to validate these changes.

Enhancements:

Tests:

github-actions[bot] commented 3 months ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
src
   __init__.py00100% 
   api.py119794%32–36, 54, 76–77, 109–110
   art.py9367%24–25, 28
   cli.py250100% 
   dev_streamlit.py37370%1–86
   gpt.py10640%16–21, 32–45
   helper.py1243869%110, 121–125, 201–209, 221, 234–235, 266, 268–269, 292–293, 356–366, 373–381
   send_email.py24240%5–48
   server.py471079%55, 68–71, 87–91, 103–105
   settings.py220100% 
   streamlit_helper.py33330%5–90
TOTAL45015865% 

Tests Skipped Failures Errors Time
11 0 :zzz: 0 :x: 0 :fire: 21.077s :stopwatch:
sourcery-ai[bot] commented 3 months ago

Reviewer's Guide by Sourcery

This pull request focuses on refactoring the code for better readability, maintainability, and consistency. Key changes include updating docstrings, using dictionaries and lists for argument mappings, and modifying return types. Additionally, tests have been added and updated to validate the new implementations.

File-Level Changes

Files Changes
src/helper.py
src/api.py
Refactored functions to improve readability and maintainability by using dictionaries and lists for mappings, and updated return types for consistency.
tests/test_helper.py
tests/test_api.py
Added and updated tests to validate the new implementations and ensure correctness of JSON output and forecast data.

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
K-dash commented 3 months ago

@ryansurf I'll be reviewing it tonight, so hold on a bit!

ryansurf commented 3 months ago

@ryansurf I'll be reviewing it tonight, so hold on a bit!

No rush!