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

Disable mypy "method-assign" errors in tests module #1317

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

jonathangreen
Copy link
Member

Description

Add mypy override for our tests module, that disables the "method-assign" error, and remove existing comments that are disabling this check.

Motivation and Context

In our tests, we often overwrite methods on classes with MagicMock to mock out some behaviour. Mypy doesn't like this and throws a "method-assign" error. Until now, we've been adding # type: ignore[method-assign] comments to disable this where we need to use mocks.

This PR instead removes those existing comments, and disables this check for the tests package. It is still enabled for our normal code, where we should not be mocking like this.

This is the recommended work-around from the mypy issue here: python/mypy#2427

How Has This Been Tested?

  • Running mypy locally

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen requested a review from a team August 9, 2023 13:25
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

#️⃣🔥

@jonathangreen jonathangreen merged commit 00a3e36 into main Aug 9, 2023
@jonathangreen jonathangreen deleted the feature/mypy-allow-method-assign-in-tests branch August 9, 2023 21:29
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