OSeMOSYS / otoole

OSeMOSYS Tools for Energy
https://otoole.readthedocs.io
MIT License
23 stars 17 forks source link

[Bug]: `datetime` giving warning when using Python `3.12.0` #212

Open trevorb1 opened 8 months ago

trevorb1 commented 8 months ago

The Issue

If I install otoole from a new environment, python 3.12.0 is installed by default. When running tests, the warnings shown below are produced from the datetime module. If I use python 3.11.5, these warnings are not produced.

Expected Behavior

Tests pass without warnings

Steps To Reproduce

  1. Create new conda environment conda create -n otoole
  2. Check python version is 3.12.0 with conda list python
  3. Install otoole via pip install otoole
  4. Install tox via pip install tox
  5. Run tests with tox

Log output

============================================================ warnings summary ============================================================
.tox/default/lib/python3.12/site-packages/dateutil/tz/tz.py:37
  /home/trevorb1/master/otoole/.tox/default/lib/python3.12/site-packages/dateutil/tz/tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    EPOCH = datetime.datetime.utcfromtimestamp(0)

tests/test_convert.py: 7 warnings
tests/test_read_strategies.py: 2 warnings
tests/test_utils.py: 2 warnings
tests/test_write_strategies.py: 1 warning
  /home/trevorb1/master/otoole/.tox/default/lib/python3.12/site-packages/openpyxl/packaging/core.py:99: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    now = datetime.datetime.utcnow()

tests/test_convert.py::TestWrite::test_write_excel
tests/test_write_strategies.py::TestWriteExcel::test_write_out_empty_dataframe
  /home/trevorb1/master/otoole/.tox/default/lib/python3.12/site-packages/openpyxl/writer/excel.py:292: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    workbook.properties.modified = datetime.datetime.utcnow()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.12.0-final-0 -----------
Coverage HTML written to dir htmlcov

============================================== 209 passed, 1 skipped, 15 warnings in 50.15s ==============================================

Operating System

Linux

What version of otoole are you running?

1.1.2

Possible Solution

No response

Anything else?

Issue was originally flagged in PR #211