thombashi / pytablewriter

pytablewriter is a Python library to write a table in various formats: AsciiDoc / CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.
https://pytablewriter.rtfd.io/
MIT License
611 stars 43 forks source link

DeprecationWarning: There is no current event loop #66

Open hugovk opened 1 week ago

hugovk commented 1 week ago

With this:

import pytablewriter

def main():
    writer = pytablewriter.HtmlTableWriter()
    writer.table_name = "example_table"
    writer.headers = ["int", "float", "str", "bool", "mix", "time"]
    writer.value_matrix = [
        [0,   0.1,      "hoge", True,   0,      "2017-01-01 03:04:05+0900"],
        [2,   "-2.23",  "foo",  False,  None,   "2017-12-23 45:01:23+0900"],
        [3,   0,        "bar",  "true",  "inf", "2017-03-03 33:44:55+0900"],
        [-10, -9.9,     "",     "FALSE", "nan", "2017-01-01 00:00:00+0900"],
    ]

    writer.dumps()  # or writer.write_table()

if __name__ == "__main__":
    main()

There's a deprecation warning from the writer.dumps() line starting in Python 3.12 and 3.13:

❯ python3.12 -Wall 1.py
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/dominate/dom_tag.py:74: DeprecationWarning: There is no current event loop
  if get_event_loop().is_running():

Perhaps this is something that needs fixing in dominate and not pytablewriter?