Skip to content

Update mypy to 1.20.1#1542

Merged
hynek merged 2 commits intopython-attrs:mainfrom
LecrisUT:update/mypy
Apr 13, 2026
Merged

Update mypy to 1.20.1#1542
hynek merged 2 commits intopython-attrs:mainfrom
LecrisUT:update/mypy

Conversation

@LecrisUT
Copy link
Copy Markdown
Contributor

Summary

Noticed that the tests were failing locally but not in CI in my recent PR, and turned out it was mypy not working with the latest version. I don't know what the policy is for supporting older mypy so here is a more minimal patch to make it work with the version in the uv.lock. Fwiw, Fedora's tests do not run the mypy tests.

Pull Request Check List

  • I acknowledge this project's AI policy.
  • This pull requests is not from my main branch.
  • There's tests for all new and changed code.
  • Changes or additions to public APIs are reflected in our type stubs (files ending in .pyi).
    • ...and used in the stub test file typing-examples/baseline.py or, if necessary, typing-examples/mypy.py.
    • If they've been added to attr/__init__.pyi, they've also been re-imported in attrs/__init__.pyi.
  • The documentation has been updated.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changes to the signatures of @attr.s() and @attrs.define() have to be added by hand too.
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
      The next version is the second number in the current release + 1.
      The first number represents the current year.
      So if the current version on PyPI is 26.2.0, the next version is gonna be 26.3.0.
      If the next version is the first in the new year, it'll be 27.1.0.
    • Documentation in .rst and .md files is written using semantic newlines.
  • Changes have news fragments in changelog.d.

Copy link
Copy Markdown
Member

@hynek hynek left a comment

Choose a reason for hiding this comment

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

oh my god it they changed the syntax all again – thanks for the fix!

@hynek hynek added this pull request to the merge queue Apr 13, 2026
Merged via the queue into python-attrs:main with commit 834136e Apr 13, 2026
17 checks passed
@hynek
Copy link
Copy Markdown
Member

hynek commented Apr 13, 2026

OK, it might be that we have to revert this and talk to the Mypy people. With both 1.20.0 and 1.20.1, the pytest -k test_mypy passes for me only once which makes no sense:

CleanShot 2026-04-13 at 19 55 40

Does it work for you reliably?

cc @Tinche

@LecrisUT
Copy link
Copy Markdown
Contributor Author

LecrisUT commented Apr 13, 2026

Does it work for you reliably?

That is really weird, yes it works reliably for me, although I did not run it with uv run, just directly pytest -k mypy 🤔.

Edit: Ok I've ran them with uv as well and it worked on my side. What black magic is going on?

@hynek
Copy link
Copy Markdown
Member

hynek commented Apr 13, 2026

what platform are you on?

@LecrisUT
Copy link
Copy Markdown
Contributor Author

what platform are you on?

Linux (Fedora). I reckon it's not specific to me and could replicate in a container

@hynek
Copy link
Copy Markdown
Member

hynek commented Apr 13, 2026

I mean I am the one who has a weirdly behaving Mypy. :) And I'm on macOS.

@LecrisUT
Copy link
Copy Markdown
Contributor Author

Well, at least in the worst case those test cases can be converted to a regex 🙃

@hynek
Copy link
Copy Markdown
Member

hynek commented Apr 14, 2026

looks like I "fixed" it by disabling caching on that test #1546

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