Skip to content
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

Fix mypy version check #3783

Merged
merged 4 commits into from
Aug 12, 2022
Merged

Fix mypy version check #3783

merged 4 commits into from
Aug 12, 2022

Conversation

KotlinIsland
Copy link
Contributor

@KotlinIsland KotlinIsland commented Feb 5, 2022

Change Summary

Basically the mypy plugin is broken with any dev version of mypy, I changed how the version number is parsed.

>mypy --version 
mypy 0.940+dev.04cac4b5d911c4f9529e6ce86a27b44f28846f5d.dirty

>mypy test.py       
pyproject.toml:1: error: Error importing plugin "pydantic.mypy": could not convert string to float: 
Found 1 error in 1 file (errors prevented further checking)

Also mypy will switch to a version number like x.y.z which the current check will fail on. It will be better to future proof this check to prevent a sudden wave of reports of "could not convert string to float".

Related issue number

N/A

Checklist

  • [N/A] Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@KotlinIsland
Copy link
Contributor Author

please review

@samuelcolvin
Copy link
Member

LGTM, please add a change description.

@KotlinIsland
Copy link
Contributor Author

This is not optimal, it should ideally use the version string passed from mypy, not import from mypy.version.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

Looking good, you'll need to rebase or merge master to get tests passing.

pydantic/mypy.py Outdated
Comment on lines 71 to 72
MYPY_VERSION = tuple(int(part) for part in mypy_version.split('+')[0].split('.'))
BUILTINS_NAME = 'builtins' if MYPY_VERSION >= (0, 930) else '__builtins__'
Copy link
Member

Choose a reason for hiding this comment

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

Please move this into a function so we can test some real life values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like that?

@samuelcolvin
Copy link
Member

please update.

pydantic/mypy.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting author revision awaiting changes from the PR author and removed ready for review labels Aug 8, 2022
@github-actions github-actions bot assigned KotlinIsland and unassigned samuelcolvin Aug 8, 2022
@samuelcolvin samuelcolvin merged commit 0360691 into pydantic:master Aug 12, 2022
@samuelcolvin
Copy link
Member

thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting author revision awaiting changes from the PR author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants