Skip to content

chore: speed up mypy runs - #2759

Open
MortGron wants to merge 3 commits into
masterfrom
mypy-v2
Open

chore: speed up mypy runs#2759
MortGron wants to merge 3 commits into
masterfrom
mypy-v2

Conversation

@MortGron

@MortGron MortGron commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Description

Make mypy run faster by upgrading to v2 and enabling parallel type checking, which was introduced in Mypy v2. In one file a number of type: ignore comments have been removed, and 1 added.

Also the optional faster cache extra has been added.

In addition, some legacy Mypy config options that are undocumented in the Mypy documentation have been replaced by their modern equivalents, or removed if they are not needed anymore.

Checklist:

  • Tests added/updated.
  • Documentation updated. Documentation is generated from docstrings - these must be updated according to your change.
    If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.
  • The PR title follows the Conventional Commit spec.

@MortGron
MortGron marked this pull request as ready for review August 9, 2026 21:37
@MortGron
MortGron requested review from a team as code owners August 9, 2026 21:37

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request attempts to upgrade mypy to version 2.3.0 and adjusts type-checking configurations. However, a critical security vulnerability was identified as the mypy v2 upgrade and its new dependency ast-serialize appear to be a malicious supply chain attack. Additionally, the removal of no_implicit_optional in mypy.ini violates type safety guidelines.

Comment thread pyproject.toml
Comment thread mypy.ini
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (3ba438e) to head (cc2cb1e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2759      +/-   ##
==========================================
- Coverage   93.79%   93.76%   -0.04%     
==========================================
  Files         509      509              
  Lines       52263    52263              
==========================================
- Hits        49020    49002      -18     
- Misses       3243     3261      +18     
Files with missing lines Coverage Δ
cognite/client/data_classes/capabilities.py 97.07% <100.00%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@haakonvt haakonvt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!!

@MortGron MortGron added the waiting-for-risk-review Waiting for a member of the risk review team to take an action label Aug 10, 2026
@andersfylling

Copy link
Copy Markdown
Contributor

what is the before and after duration?

@MortGron

Copy link
Copy Markdown
Contributor Author

what is the before and after duration?

Before
image

After
image

So about 30 % faster on my machine

@thorkildcognite thorkildcognite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I approve of the change, but let's wait until Thursday so the grace period on ast-serialize is 7 days for the 0.8.0 dependency. Ping me if I don't remember to do the 🦄 then.

scope: AllScope

class Action(Capability.Action): # type: ignore [misc]
class Action(Capability.Action):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice to get rid of all of these type-ignores!

Comment thread poetry.lock
]

[[package]]
name = "ast-serialize"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a brand new release, and although all commits in this new release looks fine (although the ruff one of 250k is hard to check), it breaks with our "minimum 7 day old" version restriction.

Again, the commits on ast-serialize look safe for the 0.8.0 release, and it again pulls in pyO3 that is newer etc.

Let's wait until Wednesday or Thursday to merge this fix to be consistent with our paranoia level.

@thorkildcognite thorkildcognite self-assigned this Aug 10, 2026
@thorkildcognite thorkildcognite added the risk-review-ongoing Risk review is in progress label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk-review-ongoing Risk review is in progress waiting-for-risk-review Waiting for a member of the risk review team to take an action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants