wmo-im / wis2downloader

The backend Python package for downloading real-time data from the WIS2 network.
Apache License 2.0
0 stars 0 forks source link

TypeError when config environment variable is None #20

Closed RoryPTB closed 3 months ago

RoryPTB commented 3 months ago

If the WIS2DOWNLOADER_CONFIG exists but is None, it is not caught in config.py:

 wis2downloader
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\rptb2\Code\WMO\Downloader\Backend\venv\Scripts\wis2downloader.exe\__main__.py", line 4, in <module>
  File "C:\Users\rptb2\Code\WMO\Downloader\Backend\venv\Lib\site-packages\wis2downloader\app.py", line 25, in <module>
    CONFIG = load_config()
             ^^^^^^^^^^^^^
  File "C:\Users\rptb2\Code\WMO\Downloader\Backend\venv\Lib\site-packages\wis2downloader\utils\config.py", line 16, in load_config
    config_file = Path(config_file)
                  ^^^^^^^^^^^^^^^^^
  File "C:\Users\rptb2\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 871, in __new__
    self = cls._from_parts(args)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rptb2\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 509, in _from_parts
    drv, root, parts = self._parse_args(args)
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rptb2\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 493, in _parse_args
    a = os.fspath(a)
        ^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType

To fix this, an additional NoneType check should be added to config.py.

david-i-berry commented 3 months ago

Fixed by PR #21