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

Fix local variable 'activities' referenced before assignment #11

Merged
merged 1 commit into from
Feb 10, 2022

Conversation

hugovk
Copy link
Collaborator

@hugovk hugovk commented Feb 10, 2022

Followup to #10.

From CI:

Traceback (most recent call last):
Plotting landscape...
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\runpy.py", line 193, in _run_module_as_main
Saved to strava-landscape.png
    "__main__", mod_spec)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\Scripts\stravavis.exe\__main__.py", line 7, in <module>
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\site-packages\stravavis\cli.py", line [72](https://github.com/marcusvolz/strava_py/runs/5136794948?check_suite_focus=true#step:5:72), in main
    if activities:
UnboundLocalError: local variable 'activities' referenced before assignment
Error: Process completed with exit code 1.

https://github.com/marcusvolz/strava_py/runs/5136794948?check_suite_focus=true

Need to initialise activities = None in case this if doesn't run:

    activities = None
    if args.activities_path:
        print("Processing activities...")
        activities = process_activities(args.activities_path)

So there's a variable to check here:

    if activities:
        print("Plotting calendar...")
        outfile = f"{args.output_prefix}-calendar.png"
        plot_calendar(activities, output_file=outfile)
        print(f"Saved to {outfile}")

@marcusvolz marcusvolz merged commit 0723280 into marcusvolz:main Feb 10, 2022
@hugovk hugovk deleted the fix-UnboundLocalError branch February 10, 2022 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants