Add type hints in pulser.parametrized [unitaryHACK] (#16)#175
Add type hints in pulser.parametrized [unitaryHACK] (#16)#175HGSilveri merged 17 commits intopasqal-io:developfrom
pulser.parametrized [unitaryHACK] (#16)#175Conversation
The I'll review this asap. Make sure to address all the errors in the CI tests in the mean time. |
Okay, have corrected the errors in the CI test, updating the type hints on |
HGSilveri
left a comment
There was a problem hiding this comment.
Alright, here are a few comments. Try to be more specific when you can (e.g. if you know the type of the keys and values of a dict, type-hint them too).
…pe-hint-parametrized
…/Pulser into type-hint-parametrized
Okay @HGSilveri, I'm on it. Updates -
|
Try to change that line to |
|
Hey @HGSilveri, I have updated the suggested changes. |
HGSilveri
left a comment
There was a problem hiding this comment.
Alright, it's getting there!
|
Done |
HGSilveri
left a comment
There was a problem hiding this comment.
Alright, it's getting there! The next commit should do it
|
Done |
| from abc import ABC, abstractmethod | ||
| from typing import Dict, Any | ||
|
|
||
| from pulser.parametrized import Variable |
There was a problem hiding this comment.
This is what giving you the test error. Try this instead:
| from pulser.parametrized import Variable | |
| from pulser.parametrized.variable import Variable |
There was a problem hiding this comment.
If this doesn't work either, there's another option, but try this first.
There was a problem hiding this comment.
Ok, it didn't work. Try this then:
from typing import Dict, Any, TYPE_CHECKING
if TYPE_CHECKING:
from pulser.parametrized import Variable
There was a problem hiding this comment.
Okay, updating it.
There was a problem hiding this comment.
You have another import like this, you should change it too
| from pulser.parametrized import Parametrized, Variable | ||
| from pulser.json.utils import obj_to_dict | ||
| if TYPE_CHECKING: | ||
| from pulser.parametrized import Parametrized, Variable |
There was a problem hiding this comment.
You can't really do this because Parametrized is needed even when you're not type checking. You have to split the import into two lines
|
Okay, now you have a coverage problem, which is to be expected... just add |
Thanks for the guidance! 😃 |
Type checked on
decorators.py,paramabc.py,paramobj.pyandvariable.pyI have some doubts about the return type of the
buildfunction.