mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Fix incorrect join in the presence of Any fallback

Open hauntsaninja opened this issue 3 years ago • 3 comments

Fixes #11925

This avoids mypy from guessing subtype relationships because of the any fallback over here: https://github.com/python/mypy/blob/e1bfb75ed2187db76d51ed875ce953da3ba4d02c/mypy/subtypes.py#L438

hauntsaninja avatar Jan 06 '23 05:01 hauntsaninja

Diff from mypy_primer, showing the effect of this PR on open source code:

kornia (https://github.com/kornia/kornia)
- kornia/nerf/nerf_model.py:121: error: "object" not callable  [operator]

github-actions[bot] avatar Jan 06 '23 07:01 github-actions[bot]

cc @ilevkivskyi could you review? The check_context assertion comes from https://github.com/python/mypy/pull/13303 , as far as I can see no changes are required for ignore_type_params=True, but I might be missing something

hauntsaninja avatar Jan 09 '23 06:01 hauntsaninja

Diff from mypy_primer, showing the effect of this PR on open source code:

kornia (https://github.com/kornia/kornia)
- kornia/nerf/nerf_model.py:121: error: "object" not callable  [operator]

github-actions[bot] avatar Jan 09 '23 06:01 github-actions[bot]

I finally got some time to think about this. In general, those asserts were added when two visitors were merged to prevent accidentally going through previously completely untested code paths. Also I don't really like ignore_type_params for proper subtypes, but after all I think it is not a big deal, so if this doesn't cause problems, let's just keep this.

ilevkivskyi avatar Jan 29 '23 19:01 ilevkivskyi