pyquil icon indicating copy to clipboard operation
pyquil copied to clipboard

Eventually upgrade mypy

Open appleby opened this issue 5 years ago • 4 comments

In #1119 @erichulburd noticed that make typecheck was failing with mypy 0.750 and so pinned our mypy dependency to 0.740 as a workaround.

The type errors on mypy 0.750 stem from the definition of ExpressionDesignator in quilatom.py, which is a nested Union type like so:

ExpressionValueDesignator = Union[int, float, complex]
ExpressionDesignator = Union['Expression', ExpressionValueDesignator]

Long story short, mypy 0.750 doesn't like the nested ExpressionValueDesignator.

As a workaround, flattening the Union like so resolves the issue:

ExpressionValueDesignator = Union[int, float, complex]
-ExpressionDesignator = Union['Expression', ExpressionValueDesignator]
+ExpressionDesignator = Union['Expression', int, float, complex]

I've opened a mypy issue upstream.

For now we should just keep mypy pinned to 0.740, but when/if the above mypy issue is addressed, we me might consider upgrading, or else apply the above patch if the mypy issue is resolved as "wont fix".

appleby avatar Dec 10 '19 15:12 appleby

The upstream mypy issue was fixed in https://github.com/python/mypy/pull/8146.

Should be safe to upgrade to the whatever the next release is after 0.750.

appleby avatar Dec 20 '19 20:12 appleby

I think although the issue is fixed in python/mypy#8146, it will be not in the release until v0.770(the most recent release is v0.761 where this PR has not merged yet), so you may still stay with v0.740 for maybe a month(or shorter) till v0.770 comes out.

TH3CHARLie avatar Dec 21 '19 02:12 TH3CHARLie

Good to know @TH3CHARLie thanks for the heads up (and for fixing the bug :-)

appleby avatar Dec 21 '19 03:12 appleby

Mypy 0.770 was out 22 days ago: https://github.com/python/mypy/releases/tag/v0.770.

rht avatar Mar 31 '20 11:03 rht