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

Error when running type checks #2033

Closed
purva-thakre opened this issue Sep 28, 2023 · 5 comments
Closed

Error when running type checks #2033

purva-thakre opened this issue Sep 28, 2023 · 5 comments
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@purva-thakre
Copy link
Collaborator

purva-thakre commented Sep 28, 2023

Issue Description

If type checks are done locally, the following errors are raised.

mitiq/observable/observable.py:185: error: "defaultdict" is not subscriptable, use "typing.DefaultDict" instead  [misc]
mitiq/interface/conversions.py:350: error: Item "Circuit" of "Union[Circuit, Program, Any, Any, Any]" has no attribute "qregs"  [union-attr]
mitiq/interface/conversions.py:350: error: Item "Program" of "Union[Circuit, Program, Any, Any, Any]" has no attribute "qregs"  [union-attr]
mitiq/interface/conversions.py:352: error: Item "Circuit" of "Union[Circuit, Program, Any, Any, Any]" has no attribute "cregs"  [union-attr]
mitiq/interface/conversions.py:352: error: Item "Program" of "Union[Circuit, Program, Any, Any, Any]" has no attribute "cregs"  [union-attr]
mitiq/interface/conversions.py:353: error: Item "Circuit" of "Union[Circuit, Program, Any, Any, Any]" has no attribute "cregs"  [union-attr]
mitiq/interface/conversions.py:353: error: Item "Program" of "Union[Circuit, Program, Any, Any, Any]" has no attribute "cregs"  [union-attr]

How to Reproduce

cd mitiq

make check-types
@purva-thakre purva-thakre added bug Something isn't working good first issue Good for newcomers labels Sep 28, 2023
@purva-thakre purva-thakre added this to the 0.31.0 milestone Sep 29, 2023
@natestemen
Copy link
Member

Can you post the output of these commands:

mypy --version
pip list
python --version

@purva-thakre
Copy link
Collaborator Author

@natestemen Looks like my version of mypy is not what's in devrequirements.txt.

Will upgrade to a newer version and check if I get the same errors.

@purva-thakre
Copy link
Collaborator Author

I did not know check-types, check-style and check-format are run for Python 3.11 only.

https://github.com/unitaryfund/mitiq/blob/master/.github/workflows/build.yml#L26

My local environment was using Python 3.8.10 which still led to one error after installing the requirements as specified in devrequirements.txt.

mypy mitiq --show-error-codes
mitiq/observable/observable.py:185: error: "defaultdict" is not subscriptable, use "typing.DefaultDict" instead  [misc]

I propose we close this issue but add details about the checks being restricted to Python 3.11 in #2029 or we could instead change the Contributing guidelines to have a Python 3.11 environment.

@natestemen
Copy link
Member

We will be dropping support for python 3.8 soon, and I believe these errors do not occur with python 3.9.

@purva-thakre
Copy link
Collaborator Author

Closing this issue as the errors are due to an older Python environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants