Skip to content

✨ mypy support#165

Merged
phalt merged 3 commits intophalt:mypy-pluginfrom
chassing:2026-01-13_mypy
Jan 14, 2026
Merged

✨ mypy support#165
phalt merged 3 commits intophalt:mypy-pluginfrom
chassing:2026-01-13_mypy

Conversation

@chassing
Copy link
Copy Markdown
Contributor

@chassing chassing commented Jan 13, 2026

Change summary

Add a py.typed file and a mypy plugin to fully support mypy checks.

Skipping analyzing "clientele": module is installed, but missing library stubs or py.typed marker

The mypy plugin is needed to cover the clientele decorator behavior, e.g. the result and the response parameters or the pydantic model handling.

To activate the plugin, please refer to the official mypy documentation.

For example in pyproject.toml

[tool.mypy]
plugins = ["clientele.mypy"]

or in mypy.ini

[mypy]
plugins = clientele.mypy

Pull request tasks

The following have been completed for this task:

  • Code changes
  • Tests written
  • Documentation changes for new or changed features
  • Pre-review preparation
    • make test
    • make format
    • make ty
    • make generate-test-clients
      • Test clients have changed because a new feature was introduced
      • Test clients remain the same
  • Changelog updated
  • Contributors updated

Other information

Distributing type information

@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 13, 2026

@chassing great contribution, thank you! Do we need to do anything else to ensure it is bundled when running the build? We use uv, which I believe uses hatch.

@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 13, 2026

@chassing please also add your name to CONTRIBUTORS.md

@chassing
Copy link
Copy Markdown
Contributor Author

Do we need to do anything else to ensure it is bundled when running the build? We use uv, which I believe uses hatch.

I've tested it locally via [tool.uv.sources] (UV - Managing dependencies), and it worked without any additional configs in pyproject.toml

@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 13, 2026

Amazing, I'll try get this shipped today or tomorrow. Thank you :)

@chassing
Copy link
Copy Markdown
Contributor Author

chassing commented Jan 13, 2026

Amazing, I'll try get this shipped today or tomorrow. Thank you :)

Please hold. 😢

With mypy enabled, on the usage side, the missing result parameter must be ignored by mypy. Maybe this needs a mypy plugin 🤷

Missing positional argument "result" in call to "user_repos" of "GitHubConsumer"

@chassing chassing marked this pull request as draft January 13, 2026 14:09
@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 13, 2026

@chassing yes good point. Perhaps it does. This needs to be the same for both result and response - we should continue working on it in this branch.

@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 13, 2026

I have been doing some digging and I think this is solvable without a mypy plugin. It'll need some decorator magic. Leave it with me for a while.

@chassing
Copy link
Copy Markdown
Contributor Author

I have been doing some digging and I think this is solvable without a mypy plugin. It'll need some decorator magic. Leave it with me for a while.

I've got the mypy plugin ready, let me know if I should push it.

@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 14, 2026

I have worked out a way to do it without the plugin but feel free to push the code changes - I'll have a look over. Currently on the day care drop off so I'll work on it later!

@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 14, 2026

@chassing please push your mypy plugin. I am struggling to get it work a smart way - I can hide it at runtime but mypy checks the static files and doesn't work the same way, so I'm reverting my work.

@phalt phalt changed the base branch from main to 1.6.0 January 14, 2026 10:34
@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 14, 2026

Just a heads up - I am changing this to merge into the 1.6.0 feature branch that I am working on.

@chassing
Copy link
Copy Markdown
Contributor Author

@chassing please push your mypy plugin. I am struggling to get it work a smart way - I can hide it at runtime but mypy checks the static files and doesn't work the same way, so I'm reverting my work.

I'll push it soon; the tests are still missing.

@chassing chassing marked this pull request as ready for review January 14, 2026 11:43
@chassing
Copy link
Copy Markdown
Contributor Author

@phalt, everything is pushed. PTAL

@chassing chassing changed the title ✨ add py.typed file ✨ mypy support Jan 14, 2026
@phalt phalt changed the base branch from 1.6.0 to mypy-plugin January 14, 2026 11:54
@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 14, 2026

I'm gonna merge this in - it makes sense to me and I've tested your branch locally. I want to extend it to support the new streaming decorators that I have been building as well. Thank you so much for this contribution :)

@phalt phalt merged commit 4a8c534 into phalt:mypy-plugin Jan 14, 2026
@phalt
Copy link
Copy Markdown
Owner

phalt commented Jan 14, 2026

Shipped in version 1.6.0 - let me know how it works! I've added a small docs page about configuring it.

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