Skip to content

Fix __qualname__ AttributeError in fiddle config.py#603

Merged
copybara-service[bot] merged 1 commit intomainfrom
test_893119387
Apr 2, 2026
Merged

Fix __qualname__ AttributeError in fiddle config.py#603
copybara-service[bot] merged 1 commit intomainfrom
test_893119387

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service bot commented Apr 1, 2026

Fix __qualname__ AttributeError in fiddle config.py

If a partial function generated by functools.partial is passed into
fiddle AND certain exceptions are raised, accessing __qualname__
will trigger another exception, prevent the users from seeing the
real error messages.

Type type TypeOrCallableProducingT = Union[Callable[..., T], Type[T]]
does not guarantee that __qualname__ will exist.

  • Added a regression test case in third_party/py/fiddle/_src/config_test.py that uses functools.partial to trigger the bug.
  • Replace all self.__fn_or_cls__.__qualname__ with the existing self._fn_or_cls_name_repr() which already solved the problem.

@copybara-service copybara-service bot force-pushed the test_893119387 branch 6 times, most recently from 75479c2 to 908daa2 Compare April 2, 2026 21:19
If a partial function generated by `functools.partial` is passed into
fiddle AND certain exceptions are raised, accessing `__qualname__`
will trigger another exception, prevent the users from seeing the
real error messages.

Type type `TypeOrCallableProducingT = Union[Callable[..., T], Type[T]]`
does not guarantee that `__qualname__` will exist.

- Added a regression test case in third_party/py/fiddle/_src/config_test.py that uses functools.partial to trigger the bug.
- Replace all `self.__fn_or_cls__.__qualname__` with the existing `self._fn_or_cls_name_repr()` which already solved the problem.

PiperOrigin-RevId: 893707305
@copybara-service copybara-service bot merged commit 5502465 into main Apr 2, 2026
@copybara-service copybara-service bot deleted the test_893119387 branch April 2, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant