Closed freider closed 1 month ago
@prbot approve
Ah, good question! We are in some other cases, but I don't think we are here, so it may have been a lucky coincidence that it's actually imported and works for me when I just tested this. Will add it to self.imports in a followup PR to make sure it's always imported if this code path is used
On Wed, Aug 14, 2024 at 3:27 PM Michael Waskom @.***> wrote:
@.**** commented on this pull request.
In synchronicity/type_stubs.py https://github.com/modal-labs/synchronicity/pull/147#discussion_r1716926776 :
@@ -781,6 +781,22 @@ def _get_function_source( body_indent: str, transform_signature=None, ) -> str:
- maybe_decorators = ""
- if hasattr(func, "__dataclass_transform__"):
- dt_spec = func.__dataclass_transform__
- if dt_spec["field_specifiers"]:
- refs = ""
- for field_spec_entity in dt_spec["field_specifiers"]:
- if field_spec_entity.module == self.target_module:
- ref = field_spec_entity.qualname
- else:
- self.imports.add(field_spec_entity.module)
- ref = f"{field_spec_entity.module}.{field_spec_entity.qualname}"
- refs += ref + ", "
- args = f"field_specifiers=({refs})"
- maybe_decorators = @.***_extensions.dataclass_transform({args})\n"
That makes sense — but are we guaranteed to have typing_extensions imported in the type stubs we emit?
— Reply to this email directly, view it on GitHub https://github.com/modal-labs/synchronicity/pull/147#discussion_r1716926776, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASII2S6V52ZG2ND4CIJY6LZRNLKPAVCNFSM6AAAAABMQD7C4KVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDEMZYGE3DOMBVHA . You are receiving this because you modified the open/close state.Message ID: @.***>
Ensures that functions like this:
maintain their dataclass_transform decorator in a generated type stub