Skip to content

maint: add pre-commit, mypy, testing docker#473

Merged
Otto-AA merged 4 commits intoboxed:mainfrom
lyft:nicklafleur/pre-commit
Mar 1, 2026
Merged

maint: add pre-commit, mypy, testing docker#473
Otto-AA merged 4 commits intoboxed:mainfrom
lyft:nicklafleur/pre-commit

Conversation

@nicklafleur
Copy link
Contributor

👋 Hi there mutmut maintainers.

We at Lyft have been tinkering internally with mutmut as a means to integrate some new approaches to testing and test quality evaluation. We've made some pretty considerable refactors to the framework that we would like to start merging to the upstream, but wanted to start with some housekeeping items as a show of good faith and thanks for all your work so far.

A sneak peak of some of the changes we have made so far are (all broken down into manageable commits and PRs of course):

  • Support for Enums, @classmethods, and @staticmethods
  • New pragma annotation support for scoped ignoring of classes and functions
  • Performance optimizations resulting in >95% runtime reductions for incremental testing
  • New run isolation modes to support various libraries that pollute the process state
  • Transitive dependency tracking and UI improvements
  • and more!

Please feel free to reach out to me directly at nicholaslafleur@lyft.com if you would like to discuss.

Copy link
Collaborator

@Otto-AA Otto-AA left a comment

Choose a reason for hiding this comment

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

Thanks for the work, I'm curious to see what you changed :)

This PR looks fine, and I like that formatting is done in a separate PR for easier reviewing. Some notes:

I think we should exclude e2e_projects and tests/data/test_generation folders, the changes there caused the tests to fail. Some of the code there has "perfect imperfections" (as noted in the comments, we want to test that mutmut can handle code stretching over multiple lines, and stuff like Union). I don't really mind if the code quality there is bad.

The pre-commit version is pretty outdated (~3 years), is there a particular reason for this? If using an up-to-date version would cause merge-conflicts, we can postpone upgrading until you submitted the other PRs.

And small documentation nitpick: I like that formatting is not validated as part of the CI, so we keep it simple for new contributors. However, I think we could add pre-commit to the dev-dependencies (uv add --dev pre-commit ), and mention pre-commit install in the CONTRIBUTING page for motivated users

@nicklafleur nicklafleur marked this pull request as draft February 28, 2026 15:44
@nicklafleur
Copy link
Contributor Author

@Otto-AA thanks for the review, I have the complete public set of changes here https://github.com/lyft/mutmut/tree/nicklafleur/oss-complete that you can check out. It's quite substantial (+15k, -3k) but everything is very malleable in my mind and open to debate. We are by no means blocked internally so happy to evolve things in a measured way here.

Working on your suggestions now :)

@nicklafleur nicklafleur force-pushed the nicklafleur/pre-commit branch 3 times, most recently from 90a1798 to 6bb6a62 Compare February 28, 2026 17:10
@nicklafleur nicklafleur requested a review from Otto-AA February 28, 2026 17:11
@nicklafleur nicklafleur marked this pull request as ready for review February 28, 2026 17:12
@nicklafleur
Copy link
Contributor Author

I believe I've addressed all the changes. All the snapshots being changed to segfault codes is due to setproctitle which I have a fix coming for in a future PR. Happy to just reset it to the remote version if you would prefer.

@nicklafleur nicklafleur force-pushed the nicklafleur/pre-commit branch from 6bb6a62 to 0cefa52 Compare February 28, 2026 21:06
@nicklafleur nicklafleur force-pushed the nicklafleur/pre-commit branch from 0cefa52 to 804fef9 Compare February 28, 2026 23:32
@Otto-AA
Copy link
Collaborator

Otto-AA commented Feb 28, 2026

Thanks, I'll try to take a look tomorrow.

All the snapshots being changed to segfault codes is due to setproctitle which I have a fix coming for in a future PR. Happy to just reset it to the remote version if you would prefer.

Yes, I'd prefer if the CI continues to pass (which runs on Linux). If it's easier for you, you can also pytest.mark.skipif the test on MacOS and also could add a temporary copy of the test that only runs on MacOS with the segfault errors.

@nicklafleur nicklafleur force-pushed the nicklafleur/pre-commit branch from 804fef9 to b9c454c Compare March 1, 2026 01:00
@nicklafleur
Copy link
Contributor Author

Yes, I'd prefer if the CI continues to pass (which runs on Linux). If it's easier for you, you can also pytest.mark.skipif the test on MacOS and also could add a temporary copy of the test that only runs on MacOS with the segfault errors.

No problem, should have thought to spin up a container for this anyways, let me just do that.

@nicklafleur nicklafleur force-pushed the nicklafleur/pre-commit branch from 5817014 to e4683da Compare March 1, 2026 02:52
@nicklafleur nicklafleur changed the title maint: add pre-commit maint: add pre-commit, mypy, testing docker Mar 1, 2026
Additions:
- /docker/Dockerfile.test which runs the tests inside a linux container
  with python 3.10
- /scripts/run_tests.sh runs the above

Documentation:
- How to use the above
Adds all type annotations to satisfy mypy. There should be 0 functional
changes.
@nicklafleur nicklafleur force-pushed the nicklafleur/pre-commit branch from e4683da to 92e54ad Compare March 1, 2026 03:23

ENV UV_PROJECT_ENVIRONMENT=/opt/venv

COPY . .
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just FYI, this will cause any change to the source code to re-execute the RUN uv sync --group dev command and download the packages. There are patterns to make this more efficient (iirc only copy pyproject.toml + uv.lock first, then sync, then copy the rest / use a volume mount).

So if you want better performance, you could change that. I don't mind it being like this though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, I'll add this to the next pr

@Otto-AA
Copy link
Collaborator

Otto-AA commented Mar 1, 2026

Thanks for the update, looks good and even with type checking ❤️

@Otto-AA Otto-AA merged commit 9d32d65 into boxed:main Mar 1, 2026
5 checks passed
@nicklafleur
Copy link
Contributor Author

No problem! mypy was actually part of a future commit but figured it would be better to just have all linting in the same PR.

@nicklafleur nicklafleur deleted the nicklafleur/pre-commit branch March 2, 2026 04:13
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