Skip to content

__repr__ for FirewallResourceLabelSelector broken because of missing __api_properties__ #491

@scy

Description

@scy

Bug Report

Current Behavior
Calling repr() on a FirewallResourceLabelSelector instance throws an AttributeError because the class inherits from BaseDomain (and thus comes with BaseDomain.__repr__), but does not have an __api_properties__ field.

Input Code

$ uv run --with hcloud==2.5.0 python
Python 3.13.1 (main, Dec 19 2024, 14:32:25) [Clang 18.1.8 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hcloud
>>> selector = hcloud.firewalls.FirewallResourceLabelSelector("answer=42")
>>> selector
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    selector
  File "/home/scy/.cache/uv/archive-v0/0e_aaDu7yChGLL8FNzh-C/lib/python3.13/site-packages/hcloud/core/domain.py", line 18, in __repr__
    kwargs = [f"{key}={getattr(self, key)!r}" for key in self.__api_properties__]  # type: ignore[var-annotated]
                                                         ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'FirewallResourceLabelSelector' object has no attribute '__api_properties__'
>>> 

Expected behavior/code
Something like FirewallResourceLabelSelector(selector="answer=42").

Environment

  • Python Version: 3.13.1
  • Hcloud-Python Version: 2.5.0

Possible Solution

  1. Implement __api_properties__ on the class.
  2. Introduce some static analysis to catch issues like these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions