-
Notifications
You must be signed in to change notification settings - Fork 140
Add mypy checks in CI #813
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
base: master
Are you sure you want to change the base?
Conversation
… not need manual adjustment and manually adjusted all files in the main folder, in smtlib, in cmd and in optimization. SOlvers, test and walkers are still missing
… circular imports with environment; fixed tests that were broken by the hardcoded modifications to apply monkeytypes and started fixing mypy errors (still WIP)
…at have to be resolved
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 reviewed some of the files, in general please check the occurences of Any
|
|
||
|
|
||
| def all_types(): | ||
| def all_types() -> chain: |
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.
| def all_types() -> chain: | |
| def all_types() -> Iterable[int]: |
| for arg in args: | ||
| res.update(arg) | ||
| return frozenset(res) | ||
| return frozenset(chain([formula.function_name()], *args)) |
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.
? Why computing res if you make this change?
| self.write(")") | ||
|
|
||
| def walk_forall(self, formula): | ||
| def walk_forall(self, formula: FNode) -> Iterator[Any]: |
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.
Why Any if all other methods return FNodes?
| def walk_bv_lshr(self, formula): return self.walk_nary(formula, " >> ") | ||
| def walk_bv_ashr(self, formula): return self.walk_nary(formula, " a>> ") | ||
| def walk_bv_comp(self, formula): return self.walk_nary(formula, " bvcomp ") | ||
| def walk_and(self, formula: FNode) -> Iterator[Any]: return self.walk_nary(formula, " & ") |
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.
Why Any here and below? Should be FNode
| return self.walk_conj_disj(self.mgr.Or(na, b), [na_arg, args[1]]) | ||
|
|
||
| def walk_ite(self, formula, args, **kwargs): | ||
| def walk_ite(self, formula: FNode, args: List[Optional[Tuple[List[Any], FNode]]], **kwargs): |
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.
return type? In general, if a walk_xxx returns T all other walk_yyy should return T
|
|
||
|
|
||
| def get_model(formula, solver_name=None, logic=None): | ||
| # TODO also here mypy didn't notice that the model was not Optional (a mistake) |
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.
?
| return self.get_script(script) | ||
|
|
||
| def parse_atoms(self, tokens, command, min_size, max_size=None): | ||
| def parse_atoms(self, tokens: Tokenizer, command: str, min_size: int, max_size: Optional[int]=None) -> List[Union[Any, str]]: |
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.
Why Any here? (Also, Union[Any, str] is basically Any])
| res: Optional[Union[PartialType, PySMTType]] = None | ||
| if type_params and var in type_params: | ||
| return (var,) # This is a type parameter, it is handled recursively | ||
| return (var,) # type: ignore [return-value] # This is a type parameter, it is handled recursively # TODO is PartialType also handled recursively? |
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.
Leftover and unclear todo
| var = self.parse_atom(tokens, current) | ||
| namedparams = self.parse_named_params(tokens, current) | ||
| rtype = self.parse_type(tokens, current) | ||
| rtype = cast(PySMTType, self.parse_type(tokens, current)) # TODO is this cast correct? WHen can it be a PartialType? |
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.
Yes, this is correct.Remove the todo
| return res | ||
|
|
||
| def get(self, name): | ||
| def get(self, name: str) -> Any: |
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.
Shouldn't this be a Optional[Union[str, Callable, PySMTType, FNode, _TypeDecl])]? The get should be the revers of the bind...
This PR aims to add mypy checks in CI and bring the typing to a working state