Nevalicjus/ntfpy

Import error (python 3.10 and 3.11)

Closed this issue ยท 4 comments

Expected Behaviour

The package should be usable.

Observed Behaviour

Python exists after observing an error with the package.

Error message:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import ntfpy
  File "C:\Users\Username\AppData\Local\Programs\Python\Python310\lib\site-packages\ntfpy\__init__.py", line 1, in <module>
    from .raw_send import *
  File "C:\Users\Username\AppData\Local\Programs\Python\Python310\lib\site-packages\ntfpy\raw_send.py", line 5, in <module>
    from .types.actions import NTFYAction
  File "C:\Users\Username\AppData\Local\Programs\Python\Python310\lib\site-packages\ntfpy\types\__init__.py", line 3, in <module>
    from .client import *
  File "C:\Users\Username\AppData\Local\Programs\Python\Python310\lib\site-packages\ntfpy\types\client.py", line 10, in <module>
    from ..raw_send import raw_send, raw_send_message
ImportError: cannot import name 'raw_send' from partially initialized module 'ntfpy.raw_send' (most likely due to a circular import) (C:\Users\Username\AppData\Local\Programs\Python\Python310\lib\site-packages\ntfpy\raw_send.py)

Steps to reproduce

  1. Create a new python file with the following content:
import ntfpy
  1. Try to run the file.
  2. The script will exit with an error.

Context (Environment)

  • Windows 10
  • ntfpy version 0.0.10
  • python 3.10 and 3.11

Possible Solution

I don't know.

I am sadly aware raw_send currently is unimportable due to circulars ๐Ÿ˜…

This should be fixed in 0.0.11, but until it's released you can use the slightly longer approach of

client = NTFYClient(NTFYserver, topic, NTFYUser)
client.send(message)

The problem is that the error is still present even when using this code:

from ntfpy import NTFYClient, NTFYServer

client = NTFYClient(NTFYServer("https://ntfy.sh"), "test")
client.send("this is a test")

I can import nothing from ntfpy without an error.

Yep, noticed that myself just after responding to you;

I think I must've somehow not tested the 0.0.10 prior to publishing it; I'll veeery quickly work on the fix then ๐Ÿ˜…

Resolved after 09746bf, in v0.0.11