Summary
With the alternative syntax for TypedDict it is possible to construct one with keys that cannot be represented using the class syntax due to variable naming issues. There does not seem to be any way in polyfactory to customize these fields.
from typing import TypedDict, NotRequired
from polyfactory.factories.typed_dict_factory import TypedDictFactory
A = TypedDict("A", {"x": int, "y": NotRequired[str], "#not-valid-identifier": float})
class AFactory(TypedDictFactory[A]):
# Nothing can be done here to change the behavior for generating "#not-valid-identifier"
pass
print(AFactory.build()) # {'x': 544, 'y': 'egGRVOHCaCMUAwOchRWT', '#not-valid-identifier': 427363237424.216}
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response
Summary
With the alternative syntax for TypedDict it is possible to construct one with keys that cannot be represented using the class syntax due to variable naming issues. There does not seem to be any way in polyfactory to customize these fields.
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response