kaxil commented on code in PR #69311:
URL: https://github.com/apache/airflow/pull/69311#discussion_r3518976588


##########
airflow-core/src/airflow/partition_mappers/fixed_key.py:
##########
@@ -46,20 +43,24 @@ class FixedKeyMapper(PartitionMapper):
     :raises ValueError: if *downstream_key* is not a non-empty ``str``.
     """
 
-    downstream_key: str = attrs.field()
-
-    @downstream_key.validator
-    def _validate_downstream_key(self, attribute: attrs.Attribute, value: str) 
-> None:
-        if not isinstance(value, str) or value == "":
-            raise ValueError(f"FixedKeyMapper downstream_key must be a 
non-empty str; got {value!r}.")
+    def __init__(self, downstream_key: str, *, max_downstream_keys: int | None 
= None) -> None:

Review Comment:
   `check-partition-mapper-defaults-in-sync` will fail CI here. That prek/CI 
hook (`.pre-commit-config.yaml`, registered on this exact file) compares 
`FixedKeyMapper`'s class-body field names between core and the SDK via 
`extract_class_field_names`, which only collects top-level `AnnAssign` names 
from the class body.
   
   Moving `downstream_key` out of the class body (was `downstream_key: str = 
attrs.field()`) into `self.downstream_key = downstream_key` inside `__init__` 
means the core class now exposes no annotated field, while the SDK 
`FixedKeyMapper` is unchanged (still `@attrs.define` with `downstream_key: str 
= attrs.field()`). The two field sets diverge, so the hook exits 1.
   
   I ran the hook's own extractor against this PR's file contents to confirm:
   
   ```
   core_fields: set()
   sdk_fields:  {'downstream_key'}
   in sync?     False
   ```
   
   Simplest fix that keeps behavior identical: add a bare class-body annotation 
`downstream_key: str` above `__init__`. A bare annotation creates no class 
attribute, so `__init__` still owns the assignment, but the extractor sees the 
field again and the hook passes.



-- 
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