enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 189 forks source link

core/__init__.py: Fix attribute check #862

Open elig0n opened 5 months ago

elig0n commented 5 months ago

Addressing the issue of registering groups ( #854 ) I changed the following:

Use an empty dict as a default for default_hints Use hasattr() instead of bare object access/check

When default_hints is passed to the Status object instanciation the following error Fatal Error - ValueError(Additional arguments are invalid if 'module' is already an object) is shown.

This can be handled by excluding type of i3pystatus.group.Group in the check at L118 but I could not import the class due to:

  File "/github/i3pystatus/venv/lib/python3.11/site-packages/i3pystatus/core/__init__.py", line 6, in <module>
    from i3pystatus.group import Group
  File "/github/i3pystatus/venv/lib/python3.11/site-packages/i3pystatus/group.py", line 1, in <module>
    from i3pystatus import IntervalModule, Status, Module
ImportError: cannot import name 'IntervalModule' from partially initialized module 'i3pystatus' (most likely due to a circular import) (/github/i3pystatus/venv/lib/python3.11/site-packages/i3pystatus/__init__.py)

I could fix all imports but the import of Status which also showed the above error