Skip to content

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 KotlinIsland force-pushed the master branch 2 times, most recently from 6c904df to e5dbf65 Compare February 5, 2022 05:12
@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.

@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
@KotlinIsland KotlinIsland force-pushed the master branch 4 times, most recently from f7ea9e9 to f49c0c9 Compare August 8, 2022 23:42
@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