Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[unitaryhack] Start working on mypy errors #8187
[unitaryhack] Start working on mypy errors #8187
Changes from 35 commits
2bde3a2
ca78f08
fecd5df
b07acd0
ae1987a
517011e
6a8adf7
77fd960
39bfeca
2b6119a
e98a6a1
0c19518
680d54f
74cdcca
c3995cd
44b401d
06a7fa3
27e225c
aa34e08
d6c3f96
f448848
7538012
b07fef7
ed92f01
26922da
e6e1281
f78f0c0
5001146
99b055f
b43dec0
5f656e0
4fc7899
2b11c74
34cc559
657fc57
0d2f065
2d56f46
505c2ed
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a common change here. Both algorithms and opflow used to run against mypy in Aqua before they were migrated to Terra here. Since then mypy has not been run here and some code has been added so I would have expected some issues. But mypy always internally figured the type of instance variables based on its usage so unless things were more complicated around the types, where it locked in one aspect and it was used with a different type later, in general this was not needed. @manoelmarques since you dealt more directly with mypy in this area any comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with error messages, somehow mypy couldn't figure out that it's
Optional[int]
rather thanNoneType
, and thus assignment ofint
to this variable is leading to type errorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version of mypy are you running with? I know mypy has put out new versions since we ran the code when it was in Aqua. Here for instance is a mypy ini file, for code that was migrated from Aqua, where in the applications repos we run mypy, and is updated from what we used to do in Aqua. For instance we have strict_optional set False, which allows None to be any type. What settings are you running this with. I assume you are doing this all locally since I do not see requirements-dev.txt nor CI updated to run this here yet. Maybe its too soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm running
mypy 0.970
with following commanddmypy run -- --ignore-missing-imports --no-strict-optional --allow-untyped-globals --allow-redefinition --show-error-codes qiskit
taken from #6905 (comment)I'm indeed doing it locally, since there are still ~1000 mypy errors after this PR (and ~1400 before). Fixing everything in one PR is too much, and even this PR will probably be broken into a couple of smaller ones, as discussed a bit earlier here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this should be
Tuple[float, float]
, similar to the above comments - it wouldn't hurt to make the return statementor so to make that clear as well, since the length is hardcoded in line 517.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check the code to see if the
int
type hints need changing. This PR is the right place to resolve such potentially false hints - if we're not resolving the "TODO" here, we'll probably always forget to do it.