Skip to content

chore(server): Replace mypy with ty#504

Merged
pedro-avalos merged 5 commits intomainfrom
replace-mypy
Jan 30, 2026
Merged

chore(server): Replace mypy with ty#504
pedro-avalos merged 5 commits intomainfrom
replace-mypy

Conversation

@pedro-avalos
Copy link
Copy Markdown
Collaborator

@pedro-avalos pedro-avalos commented Jan 29, 2026

Description

  • This PR replaces mypy with ty for type-checking
  • ty outperforms mypy in speed; it also is part of the Astral toolset (of which we are using more in our org).
$ time mypy src tests
Success: no issues found in 31 source files

real    0m1.038s
user    0m0.875s
sys     0m0.162s

$ time ty check src tests
All checks passed!

real    0m0.148s
user    0m0.457s
sys     0m0.147s

(In the GitHub CI, it seems to be a difference between about 7 seconds to under 0.25 seconds)

Related Issue(s)

Untracked

Testing

  • Unit tests

  • Manual testing steps:

    1. uv sync
    2. uvx tox run -e lint

Checklist

  • I have followed the contribution guidelines.
  • I have signed the Canonical CLA.
  • I have added necessary tests.
  • I have added or updated any relevant documentation (if needed).
  • I have tested the changes.

Additional Notes

I added a # ty: ignore[invalid-argument-type] comment on main.py because of an existing bug in ty that is not supporting ParamSpec at the moment. A follow-up PR should remove this once a fix is in place in ty.

This PR only replaces mypy in the Server project, not the Charm, for a couple reasons:

  1. We are not using mypy in the Charm tests
  2. When I tried to use ty (or mypy) on the Charm, I ran into a lot of errors because of the way ops packages ops.testing (ops[testing] is basically installing ops-scenario and hacking it into an ops.testing module)

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.27%. Comparing base (7d67c39) to head (f3f43e0).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #504   +/-   ##
=======================================
  Coverage   89.27%   89.27%           
=======================================
  Files          28       28           
  Lines        1417     1417           
  Branches        4        4           
=======================================
  Hits         1265     1265           
  Misses        151      151           
  Partials        1        1           
Flag Coverage Δ *Carryforward flag
charm 100.00% <ø> (ø) Carriedforward from d74abcb
client 80.24% <ø> (ø) Carriedforward from d74abcb
server 97.03% <ø> (ø) Carriedforward from d74abcb

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
Server 96.85% <ø> (ø)
Charm 97.10% <ø> (ø)
Client 80.24% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pedro-avalos pedro-avalos marked this pull request as ready for review January 29, 2026 17:44
Copy link
Copy Markdown

@rene-oromtz rene-oromtz left a comment

Choose a reason for hiding this comment

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

Looks really nice! Super simple to migrate from mypy to ty and really fast!

@pedro-avalos pedro-avalos merged commit 322b126 into main Jan 30, 2026
17 checks passed
@pedro-avalos pedro-avalos deleted the replace-mypy branch January 30, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants