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

Type all of qcodes.instrument.* except .mockers.ami430 #1817

Merged
merged 11 commits into from
Nov 12, 2019

Conversation

astafan8
Copy link
Contributor

@astafan8 astafan8 commented Nov 8, 2019

@jenshnielsen feel free to push to this branch/PR if necessary.

@codecov
Copy link

codecov bot commented Nov 11, 2019

Codecov Report

Merging #1817 into master will decrease coverage by 0.03%.
The diff coverage is 76.92%.

@@            Coverage Diff             @@
##           master    #1817      +/-   ##
==========================================
- Coverage   70.27%   70.24%   -0.04%     
==========================================
  Files         148      148              
  Lines       18572    18589      +17     
==========================================
+ Hits        13051    13057       +6     
- Misses       5521     5532      +11

Copy link
Collaborator

@jenshnielsen jenshnielsen left a comment

Choose a reason for hiding this comment

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

I think this looks good. There is scope to reduce some of the Any to something more specific

qcodes/instrument/ip.py Outdated Show resolved Hide resolved
@jenshnielsen
Copy link
Collaborator

It looks like @Dominik-Vogel is right

def my_test_func(a: float):
    return a + 1


if __name__ == "__main__":
    my_test_func(1)
    my_test_func(1.0)
    my_test_func(1.0 + 1.0j)

Type checks correctly for int and float but not for complex

@jenshnielsen
Copy link
Collaborator

And for a bit more fun

import numpy as np

def my_test_func(a: float):
    return a + 1


if __name__ == "__main__":
    my_test_func(1)
    my_test_func(1.0)
    my_test_func(1.0 + 1.0j)
    my_test_func(np.int32(1))
    my_test_func(np.float64(1))

with https://github.com/numpy/numpy-stubs installed as of master today.

(qcodes) PS C:\Users\jenielse\Desktop> mypy .\testnumtypes.py
testnumtypes.py:10: error: Argument 1 to "my_test_func" has incompatible type "complex"; expected "float"
testnumtypes.py:11: error: Argument 1 to "my_test_func" has incompatible type "int32"; expected "float"
testnumtypes.py:12: error: Argument 1 to "my_test_func" has incompatible type "float64"; expected "float"

@jenshnielsen
Copy link
Collaborator

This looks good. Only remaining point is to change all new Union[float,int] to float

@jenshnielsen jenshnielsen merged commit 4dbdba3 into microsoft:master Nov 12, 2019
@jenshnielsen jenshnielsen deleted the type-instr branch November 12, 2019 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants