gaogaotiantian commented on PR #58191:
URL: https://github.com/apache/spark/pull/58191#issuecomment-5404580716

   The change does not make it more correct. `cast` is just as bad as `type: 
ignore`. The fundamental issue is our code is wrong. Our code violates Liskov 
substitution principle (LSP). Basically, if you have a subclass B that inherits 
A, you should be able to replace all the object A() with B() without 
correctness issue. From another perspective, you can't make the pre-condition 
of B stronger than A.
   
   We have at least two violations in our code:
   
   1. `SimpleInputPartition` should not be a subclass of `InputPartition`. The 
inheritance here is wrong.
   2. `_SimpleStreamReaderWrapper` can't be a subclass of 
`DataSourceStreamReader` if it overrides `read` method with a *stronger* 
restriction (`SimpleInputPartition` is a subclass of `InputPartition` so it's 
stronger).
   
   We can't have a correct typing when we have incorrect code. We should fix 
the code, not the typing.


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