-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
fix: mypy "has-type" check #848
Conversation
src/arch/z80/peephole/evaluator.py
Outdated
@@ -106,7 +106,7 @@ class Number: | |||
|
|||
def __init__(self, value): | |||
if isinstance(value, Number): | |||
self.value = value.value | |||
self.value: Any = value.value |
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.
Should be:
self.value: int | None = value.value
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.
Great, changed!
src/arch/z80/optimizer/basicblock.py
Outdated
@@ -440,7 +440,7 @@ def optimize(self, patterns_list): | |||
"c": str(self.cpu.C) if self.cpu.C is not None else new_tmp_val(), | |||
"z": str(self.cpu.Z) if self.cpu.Z is not None else new_tmp_val(), | |||
}.get(x.lower(), new_tmp_val()) | |||
evaluator.UNARY[FN.IS_REQUIRED] = lambda x: self.is_used([x], i + len(p.patt)) | |||
evaluator.UNARY[FN.IS_REQUIRED] = lambda x: self.is_used([x], i + len(p.patt)) # type: ignore[has-type] |
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.
Here i
is int
and p
is of type OptPattern
.
Suggestion:
- add
from src.arch.z80.peephole.engine import OptPattern
at the beginning of the file. - change the function signature to:
def optimize(self, patterns_list: Sequence[OptPattern]) -> None:
- Add these to lines below the function header:
i: int
p: OptPattern
This way we can get rid of the # type: ignore
line 😉
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.
Added the variables below the function header.
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 think it's better to type the missing variables.
What do you think?
d92597c
to
678592c
Compare
678592c
to
a1fb678
Compare
No description provided.