Skip to content

fix: pyoaev crashes on Python 3.14: 'object has no attribute __annotations__' in RESTObject._create_managers #346

Description

Summary

pyoaev crashes at startup on Python 3.14. Any collector/injector that
instantiates a RESTObject (e.g. collector.create() during setup) raises:

AttributeError: 'Collector' object has no attribute '__annotations__'. Did you mean: '__annotate_func__'?

This makes the current OpenAEV-Platform/collectors images (whose Dockerfile was
bumped to python:3.14-alpine) fail to start entirely.

Stack trace

File ".../pyoaev/daemons/collector_daemon.py", line 90, in _setup
    self.api.collector.create(config, collector_icon)
File ".../pyoaev/mixins.py", line 218, in create
    return self._obj_cls(self, server_data)
File ".../pyoaev/base.py", line 54, in __init__
    self._create_managers()
File ".../pyoaev/base.py", line 160, in _create_managers
    for attr, annotation in sorted(self.__annotations__.items()):
File ".../pyoaev/base.py", line 90, in __getattr__
    raise AttributeError(message)
AttributeError: 'Collector' object has no attribute '__annotations__'

Root cause

RESTObject._create_managers() reads self.__annotations__ directly. Under
Python 3.14 (PEP 649 / PEP 749, deferred annotations), __annotations__ is no
longer guaranteed to be a plain attribute resolvable this way — and RESTObject
also overrides __getattr__, so the missing attribute raises instead of
returning an empty dict.

Suggested fix

Use inspect.get_annotations() (or walk the MRO collecting
cls.__dict__.get("__annotations__", {})) instead of self.__annotations__:

import inspect
annotations = {}
for klass in type(self).__mro__:
    annotations.update(inspect.get_annotations(klass))
for attr, annotation in sorted(annotations.items()):
    ...

Impact / context

Found while testing OpenAEV-Platform/collectors#590 (Splunk ES collector fix).
The collector image built on 3.14 does not start; I validated that PR on a 3.13
build. Until this is fixed in pyoaev, collector Dockerfiles should stay on 3.13.

Environment

  • Python 3.14 (python:3.14-alpine)
  • pyoaev from OpenAEV-Platform/client-python (current main)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugType: something isn't working (fix:).

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions