8000 Add the ability to diff by rsheeter · Pull Request #286 · googlefonts/picosvg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add the ability to diff #286

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

Merged
merged 1 commit into from
Feb 2, 2023
Merged

Add the ability to diff #286

merged 1 commit into from
Feb 2, 2023

Conversation

rsheeter
Copy link
Collaborator
@rsheeter rsheeter commented Feb 2, 2023

Handy when hacking on things

@rsheeter rsheeter requested a review from anthrotype February 2, 2023 01:53
8000

def __add__(self, other: "Vector") -> "Point":
"""Return Point translated by other Vector"""
if isinstance(other, Vector):
return self.__class__(self.x + other.x, self.y + other.y)
return NotImplemented
raise ValueError(f"Other must be a Vector, not a {type(other)}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here are due to typechecker complaining; I don't want the return type to be Point or NotImplemented

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the canonical way to implement math operator overrides is exactly to return NotImplemented when the other type isn't among the ones which the current method is capable of handling, this enables the interpreter to check if the same operator is implemented by the other side of the expression, see https://docs.python.org/3/library/numbers.html#implementing-the-arithmetic-operations

I'm surprised that pytype doesn't automatically support this..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. TIL. I will revert this part.

@anthrotype
Copy link
Member

"Add the ability to diff" -- before reading the code, I thought it was about diffing two svg files..

Copy link
Member
@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

by the way, what are you hacking on?

@rsheeter
Copy link
Collaborator Author
rsheeter commented Feb 2, 2023

I wanted to colorize Ewert. Horrible hackery @ https://github.com/rsheeter/colorize. Haven't slapped gradients on it yet but I still quite like the result:

image

@rsheeter rsheeter merged commit 383e0c1 into main Feb 2, 2023
@rsheeter rsheeter deleted the diff branch February 2, 2023 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0