Skip to content

Commit

Permalink
Correctly handle injection into dataclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
ZechCodes committed Nov 1, 2023
1 parent b38c874 commit be95663
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bevy/injectors/classes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import dataclasses
from inspect import get_annotations
from typing import Any, Generic, Type, TypeVar

Expand All @@ -22,6 +23,9 @@ def __init__(self):

def __get__(self, instance: object, owner: Type):
if instance is None:
if hasattr(owner, dataclasses._PARAMS):
return dataclasses.field(default_factory=self._inject_dependency)

return self

return self._inject_dependency()
Expand Down

0 comments on commit be95663

Please sign in to comment.