kacpermuda commented on PR #76750:
URL: https://github.com/apache/airflow/pull/76750#issuecomment-7219744197

   One thing worth pointing out first: `kw_only=True` won't actually fix the 
scenario you describe. The new fields `id`, `timestamp` and `asset_id` are 
required, so a positional construction with the 8 or 9 args valid on main still 
raises a `TypeError` (missing keyword-only arguments instead of missing 
positional ones). Keyword construction that doesn't pass the new fields fails 
the same way. The only way to make this fully non-breaking would be to give 
them defaults, making them optional even though core always sets them, which 
I'd rather avoid.
   
   There is precedent in core for required `kw_only=True` fields after 
defaulted ones: `RollupMapper` / `FanOutMapper` (#67184). But 
`airflow.listeners.types.AssetEvent` is internal to core, so I don't think any 
external construction needs to be supported here:
   
   - It's only constructed in one place, `AssetManager.register_asset_change`, 
and that call uses keyword arguments.
   - It's never constructed outside of `airflow-core`: nothing in the Task SDK 
or providers imports `airflow.listeners.types`, the SDK doesn't re-export it, 
and it isn't available on workers.
   - Listeners only receive it through the `on_asset_event_emitted` hook and 
read its attributes, so field order doesn't affect them.
   - It's never serialized, pickled, or sent to another process.
   
   I've pushed the latest commit to show what the `kw_only=True` approach would 
look like, but I'd prefer the previous one (new required fields first) if 
you're OK with it. Just say the word and I'll revert the last commit.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to