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

AssertionError: Event sender name must be specified #408

Closed
Touyu-Pan opened this issue Jan 19, 2023 · 2 comments · Fixed by #409
Closed

AssertionError: Event sender name must be specified #408

Touyu-Pan opened this issue Jan 19, 2023 · 2 comments · Fixed by #409

Comments

@Touyu-Pan
Copy link

Problem

I tried to use one_call method to fetch the forecast info for this loaction
lat: 55.761665, lon: 37.606667 ( Moscow, RU )

I got this error message

  File "/Users/jeff/data3p/.venv/lib/python3.10/site-packages/pyowm/weatherapi25/weather_manager.py", line 532, in one_call
    return one_call.OneCall.from_dict(json_data)
  File "/Users/jeff/data3p/.venv/lib/python3.10/site-packages/pyowm/weatherapi25/one_call.py", line 100, in from_dict
    alerts = [NationalWeatherAlert.from_dict(item) for item in the_dict['alerts']]
  File "/Users/jeff/data3p/.venv/lib/python3.10/site-packages/pyowm/weatherapi25/one_call.py", line 100, in <listcomp>
    alerts = [NationalWeatherAlert.from_dict(item) for item in the_dict['alerts']]
  File "/Users/jeff/data3p/.venv/lib/python3.10/site-packages/pyowm/weatherapi25/national_weather_alert.py", line 105, in from_dict
    return NationalWeatherAlert(sender, title, description, start_time, end_time, tags)
  File "/Users/jeff/data3p/.venv/lib/python3.10/site-packages/pyowm/weatherapi25/national_weather_alert.py", line 33, in __init__
    assert sender, 'Event sender name must be specified'
AssertionError: Event sender name must be specified

How to reproduce this bug

mgr.one_call(lat=55.761665, lon=37.606667)

pyowm version: 3.3.0 ( latest )
python version: 3.10.6

@lucemia
Copy link
Contributor

lucemia commented Jan 19, 2023

In this case, the return data's sender name is empty string.

[
    {
        "sender_name": "",
        "event": "Other dangers",
        "start": 1674097200,
        "end": 1674241200,
        "description": "",
        "tags": [],
    },
    {
        "sender_name": "",
        "event": "Прочие опасности",
        "start": 1674097200,
        "end": 1674241200,
        "description": "Гололедица.",
        "tags": [],
    },
    {
        "sender_name": "",
        "event": "Wind",
        "start": 1674097200,
        "end": 1674129600,
        "description": "",
        "tags": ["Wind"],
    },
    {
        "sender_name": "",
        "event": "Ветер",
        "start": 1674097200,
        "end": 1674129600,
        "description": "Местами порывы до 17 м/с.",
        "tags": ["Wind"],
    },
    {
        "sender_name": "",
        "event": "Freezing rain, icing",
        "start": 1674097200,
        "end": 1674108000,
        "description": "",
        "tags": ["Extreme temperature value", "Rain", "Black ice"],
    },
    {
        "sender_name": "",
        "event": "Гололедно - изморозевое отложение",
        "start": 1674097200,
        "end": 1674108000,
        "description": "Слабый гололед",
        "tags": ["Black ice"],
    },
]

@Harmon758
Copy link
Contributor

This was a duplicate of #399, and was already fixed with f27876f in the develop branch, which also fixed handling for empty event description strings.

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 a pull request may close this issue.

3 participants