takayoshi-makabe opened a new pull request, #3856:
URL: https://github.com/apache/iceberg-python/pull/3856

   <!--
   Thanks for opening a pull request!
   -->
   
   <!-- In the case this PR will resolve an issue, please replace 
${GITHUB_ISSUE_ID} below with the actual Github issue id. -->
   <!-- Closes #${GITHUB_ISSUE_ID} -->
   
   # Rationale for this change
   
   The `singledispatch` fallbacks in `conversions.py` describe the wrong 
operation, so an unregistered type produces a message that sends you looking in 
the wrong place. Passing a type with no registered implementation to each of 
the five entry points today:
   
   ```
   partition_to_py  Cannot convert 'foo' to unsupported type: FooUnknownType()
   to_bytes         scale does not match FooUnknownType()
   from_bytes       Cannot deserialize bytes, type FooUnknownType() not 
supported: b'foo'
   to_json          Cannot deserialize bytes, type FooUnknownType() not 
supported: foo
   from_json        Cannot deserialize bytes, type FooUnknownType() not 
supported: foo
   ```
   
   This reworks the three to follow the shape `from_bytes` already uses, so 
each names the operation it performs and the value it rejected:
   
   ```
   to_bytes         Cannot serialize to bytes, type FooUnknownType() not 
supported: b'foo'
   to_json          Cannot serialize to JSON, type FooUnknownType() not 
supported: foo
   from_json        Cannot deserialize JSON, type FooUnknownType() not 
supported: foo
   ```
   
   `partition_to_py` and `from_bytes` are already accurate and are left alone.
   
   One small change beyond the strings: `to_bytes` takes its value parameter as 
`value` instead of `_` so the message can include it, matching the other four. 
It is rendered with `!r`, like `from_bytes`, because the parameter also accepts 
`bytes`.
   
   ## Are these changes tested?
   
   Yes. `test_raise_on_unregistered_type` asserted the old `to_bytes` wording, 
so it is updated. `to_json` and `from_json` had no fallback coverage at all — 
which is how the copied text survived — so cases for both are added and all 
five entry points are now covered.
   
   ## Are there any user-facing changes?
   
   Only the text of these `TypeError` messages. No behaviour changes: the same 
inputs raise the same exception type in the same places.
   
   <!-- In the case of user-facing changes, please add the changelog label. -->
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to