Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Framba-Luca
Copy link
Collaborator

This PR aims to add mypy checks in CI and bring the typing to a working state

Framba-Luca and others added 29 commits May 27, 2025 14:26
… 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)
Copy link
Contributor

@mikand mikand left a 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:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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))
Copy link
Contributor

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]:
Copy link
Contributor

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, " & ")
Copy link
Contributor

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):
Copy link
Contributor

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)
Copy link
Contributor

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]]:
Copy link
Contributor

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?
Copy link
Contributor

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?
Copy link
Contributor

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:
Copy link
Contributor

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...

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.

3 participants