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

Revisit # type: ignore # pending ... comments #1789

Closed
cspotcode opened this issue May 18, 2023 · 2 comments
Closed

Revisit # type: ignore # pending ... comments #1789

cspotcode opened this issue May 18, 2023 · 2 comments
Labels

Comments

@cspotcode
Copy link
Collaborator

cspotcode commented May 18, 2023

This is a note that I've adopted a specific format for # type: ignore comments when they are caused by issues in upstream packages such as pyglet. In these cases, the proper fix should happen in the upstream library, not in arcade.

However, waiting for the upstream fix to be implemented, merged, and published to pypi would take too long. In the interim, arcade's CI would fail with errors. Even if we chose to ignore the errors, they would confuse beginners and obscure more meaningful errors.

In these situations, I suppress the errors with a comment of the form:

# type: ignore  # pending https://github.com/pyglet/pyglet/issues/843

This oddly-specific syntax is compatible with both mypy and pyright. Even if arcade uses pyright, it's nice to be compatible with down-stream users who may choose mypy. Mypy, for example, logs an error for # type: ignore pending but it is happy if we add that extra #.

This comment clearly links to a description of the underlying issue. It has zero changes to arcade's python syntax -- is guaranteed not to affect runtime behavior -- so hopefully it's non-controversial. When the upstream issue is fixed, we can remove the comment.

This issue serves as documentation of this convention. If appropriate, we can add it to the programming guide and close this issue.

@cspotcode cspotcode changed the title Revisit # type: ignore pending ... comments Revisit # type: ignore # pending ... comments May 18, 2023
@cspotcode
Copy link
Collaborator Author

I tweaked the formatting of the above after learning that mypy is touchy about the formatting of these comments. pyright espouses # type: ignore -- actual comment but is happy with mypy's format, # type: ignore # actual commetn

@einarf
Copy link
Member

einarf commented Jul 13, 2024

Added to CONTRIBUTING.md with a link to this issue

@einarf einarf closed this as completed Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants