Skip to content

Conversation

@danzimm
Copy link
Contributor

@danzimm danzimm commented Apr 24, 2025

This PR adds basic mypy type checking to the codebase.

Previously, type checking worked out of the box (e.g., via pylsp-mypy in Neovim with an editable install), but after #6381, mypy started reporting:
Cannot find implementation or library stub for module named 'triton'.

This is likely due to a known issue with type checkers and editable installs. As a workaround, this PR introduces a mypy.ini with a mypy_path to restore correct module resolution.

This is a small step toward making the Python codebase fully type-checkable.

@danzimm danzimm requested a review from ptillet as a code owner April 24, 2025 20:15
@danzimm danzimm requested review from Jokeren and peterbell10 April 28, 2025 12:56
@mgorny
Copy link
Contributor

mgorny commented Apr 28, 2025

Thank you! That said, wouldn't configuring it in tool.mypy section of pyproject.toml work for this?

@danzimm danzimm changed the title [python][typing] Add mypy.ini which adds python directory to MYPYPATH [python][typing] Specify mypy_path in pyproject.toml Apr 29, 2025
@danzimm
Copy link
Contributor Author

danzimm commented Apr 29, 2025

@mgorny yeah, for sure, good catch. Just updated the PR to do that

Copy link
Contributor

@mgorny mgorny left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

Copy link
Collaborator

@atalman atalman left a comment

Choose a reason for hiding this comment

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

lgtm

@danzimm danzimm merged commit aacd5c0 into triton-lang:main Apr 29, 2025
8 checks passed
@danzimm danzimm deleted the danzimm/mypyini branch April 29, 2025 13:45
FindHao pushed a commit to FindHao/triton that referenced this pull request Apr 30, 2025
This PR adds basic mypy type checking to the codebase.

Previously, type checking worked out of the box (e.g., via pylsp-mypy in
Neovim with an editable install), but after
[triton-lang#6381](triton-lang#6381), mypy started
reporting:
Cannot find implementation or library stub for module named 'triton'.

This is likely due to a known issue with type checkers and editable
installs. As a workaround, this PR introduces a mypy.ini with a
[`mypy_path`](https://mypy.readthedocs.io/en/stable/config_file.html#confval-mypy_path)
to restore correct module resolution.

This is a small step toward making the Python codebase fully
type-checkable.
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.

3 participants