+
Skip to content

Type hints #3826

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Type hints #3826

wants to merge 3 commits into from

Conversation

schriftgestalt
Copy link
Contributor

Add some type hints.

@@ -40,7 +42,7 @@ def __repr__(self):
return "<'%s' table at %x>" % (self.tableTag, id(self))

def __eq__(self, other):
if type(self) != type(other):
if not isinstance(self, type(other)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is unrelated to type hints and changes the meaning of the code. The current code is written as intended: only compare when the types match exactly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. I tried to avoid changes like this. I’ll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

flake complains about the !=. Can this changed to is not?

@@ -691,6 +691,8 @@ def write(self, writer, font, tableDict, value, repeatIndex=None):
assert writer.items[lengthIndex] == b"\xde\xad\xbe\xef"[: conv.staticSize]
writer.items[lengthIndex] = lengthWriter.getAllData()

def __repr__(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recomment to make a separate PR for changes other than type annotations.

@schriftgestalt
Copy link
Contributor Author

I fixed a few flake issues I missed. But tox is not happy at all when I run it locally. Is there anything I can do or can I ignore issues in files I didn’t touch? I have fixes some easy ones. But that is probably another PR?

@jenskutilek
Copy link
Collaborator

I think you need to from __future__ import annotations for the tests to pass in Python 3.9.

And you should format the code with black to get rid of the linter fails.

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.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载