Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make reflected binary method transparent #40

Merged
merged 2 commits into from
Aug 10, 2023
Merged

Commits on Aug 10, 2023

  1. Make reflected binary method transparent

    This PR makes reflected binary methods (i.e. `__radd__`) transparent,
    so that they map directly to the non reflected versions.
    
    This differs from the original implementation in #35 (which kept them as separate extensions).
    
    That approach had a few flaws:
    
    * The `str` representation of binary and non binary operators looked the same, which made them hard to debug. This could have been worked around by non pretty printing the reflective operators (i.e. keeping them as methods instead of operators).
    * It was hard to define replacements for reflective operators, since they really only were activated on converted/non supported types.
    
    This new method is a bit more magic, but should work for any expressions as long as their mathematical operators behave as one would
    expect for the reversed versions.
    saulshanabrook committed Aug 10, 2023
    Configuration menu
    Copy the full SHA
    ff57972 View commit details
    Browse the repository at this point in the history
  2. Black

    saulshanabrook committed Aug 10, 2023
    Configuration menu
    Copy the full SHA
    3e8ab1e View commit details
    Browse the repository at this point in the history