Skip to content

Update plugin to support mypy 1.17.0 #2149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 23, 2025
Merged

Conversation

Jazzinghen
Copy link
Contributor

@Jazzinghen Jazzinghen commented May 30, 2025

I have made things!

What was done

  • Updated parameter passing for MyPy 1.16+ compatibility in returns/contrib/mypy/_features/kind.py
  • Updated typesafety test files, mostly to match newer MyPy syntax
    • Union[A, B] → A | B
    • Tuple[A, B] → tuple[A, B]
    • Updated fully qualified type names and temporary module references
  • Fixed string representation of Hypothesis test expectations for version 6.136+ strategy format changes (Cache, defer, and truncate sampled_from repr HypothesisWorks/hypothesis#4441)

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

Closes #2148

I have not updated the readme as there is no strict reference to the supported mypy version, and it looks like the changelog contains release info, so I didn't touch that one either.

All the checks passed, even though I had to add an ignore flag in a function that was using some strange trait-based property access.

I used a solution very similar to the one used in typeddjango/django-stubs#2670 but I get the version info using importlib instead of the string in the module.

@Jazzinghen
Copy link
Contributor Author

This is strange. I haven't seen these issues on my side. 🤔

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

You updated

name = "wemake-python-styleguide"
version = "1.1.0"

Let's pin it to 1.0 for now :)

@Jazzinghen
Copy link
Contributor Author

Oh? I didn't notice. I think I might have just ran poetry update -U to get the latest version of Mypy and that updated everything in the lock file. Should I change the entry in pyproject.toml to limit the version to 1.0?

@sobolevn
Copy link
Member

sobolevn commented Jun 2, 2025

yes, please :)

@Jazzinghen
Copy link
Contributor Author

Rebased against master and pinned version

@svorcan-rho
Copy link

@sobolevn @Jazzinghen are there any plans to continue work on this PR?

@sobolevn
Copy link
Member

@svorcan-rho today [email protected] was released :)
Any help is appreciated.

@Jazzinghen
Copy link
Contributor Author

@sobolevn @Jazzinghen are there any plans to continue work on this PR?

I was waiting for approval after my last commit. Was there something missing?

@sobolevn
Copy link
Member

sobolevn commented Jul 16, 2025

the CI is still red, I would be happy to approve it after it is green :)

rarescosma added a commit to getbettr/octotail that referenced this pull request Jul 19, 2025
check if we can unpin once this is merged:
dry-python/returns#2149
@Jazzinghen
Copy link
Contributor Author

the CI is still red, I would be happy to approve it after it is green :)

A lot of errors seem to be not very related to what I did, however I'll try to fix them. They're quite a lot, I hope I won't break anything.

@sobolevn
Copy link
Member

Please, run poetry update to fix the ci :)

@Jazzinghen
Copy link
Contributor Author

I guess this PR became more of a "Update all the tests to run with the newer Mypy" than just that small change I did, haha

@Jazzinghen Jazzinghen changed the title Update plugin to support mypy 1.16.0 Update plugin to support mypy 1.17.0 Jul 22, 2025
@Jazzinghen
Copy link
Contributor Author

Everything should be fixed now.

@sobolevn
Copy link
Member

Awesome! Almost all fixed. Thank you! 👍

@Jazzinghen
Copy link
Contributor Author

This is strange. I don't get the same error on my PC. I'll try to reproduce it, otherwise I might need some more info than what the CI pipeline is printing.

@Jazzinghen
Copy link
Contributor Author

Oh, wait, the error is not generated by the command I was testing. I am dumb.

Mypy 1.17 seems to have started analyzing a lot more attributes and some
stuff does not exist in the objects checked.
@Jazzinghen
Copy link
Contributor Author

This was a pretty long debugging session, however it seems like mypy started checking for additional magic attributes. One of those, __await__, was checked in all the type aliases of KindN, even though it does not exist.
I hope this solution is the correct one, however if you have a better solution I'd like to hear about it. :D

Copy link

codecov bot commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (82ef3ef) to head (d90c543).
Report is 373 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #2149    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           80        81     +1     
  Lines         2485      2581    +96     
  Branches       437        44   -393     
==========================================
+ Hits          2485      2581    +96     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thank you so much! Amazing work! 🫶
Highly appreciate your time and effort!

@sobolevn sobolevn merged commit c6d086f into dry-python:master Jul 23, 2025
24 checks passed
@Jazzinghen
Copy link
Contributor Author

Thank you for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Returns mypy plugin crashes with mypy 1.16
3 participants