Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Sep 4, 2025

Missing type annotations can compromise test coverage. My eventual goal is to require annotations by default in all run tests.

Comment on lines 630 to 635
def __add__(self, x: Any) -> Any:
if isinstance(x, int):
return x + 1
return NotImplemented

def __radd__(self, x):
def __radd__(self, x: Any) -> Any:
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, these are part of a case that seems to be explicitly testing unannotated behavior ("test_unannotated_add_and_radd_2") -- does annotating these with Any affect that?

Copy link
Member

Choose a reason for hiding this comment

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

Incidentally, I actually started a similar patch where I worked around cases like this by adding support for # flags: --allow-untyped-defs in the run tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reverted the annotations in this test case. Annotating with Any should have only the effect of turning on type checking and type inference in the function body.

Also test using Any types as well, just in case.
@JukkaL JukkaL merged commit 7e446b4 into master Sep 5, 2025
13 checks passed
@JukkaL JukkaL deleted the mypyc-annotate-tests branch September 5, 2025 11:49
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.

4 participants