oppia: [BUG]: Mypy checks don't seem to be catching all the bugs

Describe the bug

Some Mypy errors seem to be happening randomly in contributors’ setups, though they ought to be caught all the time. The errors are actually valid errors in the codebase, which suggest that the mypy checks are not actually correct when they say that the checks are successful everywhere.

See https://github.com/oppia/oppia/pull/21568/files#r1906643429 for a concrete example and https://github.com/oppia/oppia/discussions/21615#discussion-7773647 for the corresponding discussion. https://github.com/oppia/oppia/discussions/21298 might also be related to this.

URL of the page where the issue is observed.

N/A

Steps To Reproduce

Introduce an error in the mypy type checks (e.g. undo the changes made in this file, e.g. use Image.LANCZOS (which doesn’t exist) instead of Image.Resampling.LANCZOS).

Run the mypy type checks using the same command that’s being used in GitHub Actions: python -m scripts.run_mypy_checks (see .github/actions/workflows/all_type_checks.yml).

These checks pass, but this is incorrect and they should fail.

Expected Behavior

The tests should fail due to the incorrect types in the image_services.py file.

(We should also ensure that the fix for this issue addresses https://github.com/oppia/oppia/discussions/21298 as well.)

Screenshots/Videos

No response

What device are you using?

Desktop

Operating System

Linux

What browsers are you seeing the problem on?

No response

Browser version

No response

Additional context

No response

Tips for developers

Before addressing the bug, please identify which PR caused the issue (you can follow the steps here). If you identify the PR, comment on the issue with a link to it. If not, mention the commit hash of the oldest commit you saw the bug on (and the month and year it was made in).

Then, please leave a comment with details of the approach that you plan to take to fix the issue (see example).

Note: If this is your first Oppia issue, please make sure to follow our guidelines for choosing an issue and setting things up. You will also need to show a demo of the fix working correctly on your local machine. Thanks!

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Thanks @omgupta-iitk. TBH it seems a bit odd because, in the non-docker installation, requirements.in and requirements_dev.in control all our dependencies, and the packages are supposed to be updated to match those during installation. In the mypy script, do we verify that the installation is done before running the mypy checks? If not then we might need to add a line that does that.

Could you also please check directly with @Ashu463 and @KartikSuryavanshi to see whether your hypothesis here (about packages being uploaded) is correct? Otherwise I think this might be a more general issue with a different cause. Thanks.

@omgupta-iitk Thank you for pointing out. Actually yes I was doing exactly same mistake. And go ahead to solve this as I am not working on this currently.