compas-dev / compas-dev/compas_viewer
ConfigBase's __post_init__ issue on python 3.14
- Dominant language
- Python
- Stars
- 12
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Hi, I tried for the first time compas, and compas_viewer, and ran into an issue while trying a minimal example with python 3.14 via uv, on a fedora 43 device:
```bash
File "/home/damien/testing_compas/.venv/lib64/python3.14/site-packages/compas_viewer/config.py", line 59, in __post_init__
field_type = self.__annotations__[field_name]
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MenubarConfig' object has no attribute '__annotations__'. Did you mean: '__annotate_func__'?
```
I could solve this by changing the line 59 of config.py to:
```py
field_type = type(self).__annotations__[field_name]
```
I also tried the original code with python 3.9 and the issue disappeared, so it is more a deprecation issue than a real "bug". I don't know how stupid of an idea it is to use compas_viewer in python 3.14 (I guess I will discover soon ;) ), and I don't want to open a pandora box that I have not the time to fix, but if this is only one of a few issues to make compas_viewer compatible with python 3.14, I'd be happy to make a small PR
**To Reproduce**
Steps to reproduce the behavior:
1. Fedora 43 (but I guess any OS would have the same issue), fresh uv install, using python 3.14
2. Sample script:
my pyproject.toml:
```toml
[project]
name = "testing-compas"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14"
dependencies = [
"compas>=2.15.1",
"compas-viewer>=2.0.2",
]
```
my small script:
```py
import compas
import compas_viewer
import compas.geometry
def main():
viewer = compas_viewer.Viewer()
box = compas.geometry.Box(1)
viewer.scene.add(box)
viewer.show()
if __name__ == "__main__":
main()
```
**Expected behavior**
You should get as me something like:
```bash
damien@fedora:~/testing_compas$ uv run main.py
Traceback (most recent call last):
File "/home/damien/testing_compas/main.py", line 11, in
main()
~~~~^^
File "/home/damien/testing_compas/main.py", line 5, in main
viewer = compas_viewer.Viewer()
File "/home/damien/testing_compas/.venv/lib64/python3.14/site-packages/compas_viewer/singleton.py", line 20, in __call__
instance.__init__(*args, **kwargs)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/home/damien/testing_compas/.venv/lib64/python3.14/site-packages/compas_viewer/viewer.py", line 27, in __init__
self.config = config or Config()
~~~~~~^^
File "", line 5, in __init__
File "", line 3, in __init__
File "", line 5, in __init__
File "/home/damien/testing_compas/.venv/lib64/python3.14/site-packages/compas_viewer/config.py", line 59, in __post_init__
field_type = self.__annotations__[field_name]
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MenubarConfig' object has no attribute '__annotations__'. Did you mean: '__annotate_func__'?
```
## Further step
I am going to keep on playing with compas_viewer, and I will make a small PR in a few days if the issues I bump into are manageable (and all fixes backward compatible to 3.9. Up to you to close it without merging if you don't want any change ;) If you know in advance that this is a no-no, let me know as well ;)
Anyway thanks for developing compas !
This makes me very happy :
Contributor guide
Assessment
This issue has not been assessed yet.