-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Followup changes to fix ruff & pyright warnings #203
Changes from 2 commits
fae40ed
890d5f1
4d2c058
a2720fb
ae2aa38
4683361
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,22 @@ | |
class ParseError(Exception): ... | ||
|
||
|
||
class ColumnAgnosticStatement(Statement): | ||
def __eq__(self, other: object) -> bool: | ||
assert isinstance(other, Statement) | ||
return ( | ||
self.name == other.name | ||
and self.lineno == other.lineno | ||
and ( | ||
self.col_offset == other.col_offset | ||
or -1 in (self.col_offset, other.col_offset) | ||
) | ||
) | ||
|
||
def __hash__(self) -> int: | ||
raise NotImplementedError | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That could cause objects that are equal to have different hashes (because Rereading it now, it turns out I misread that originally and I didn't have to complicate things as much as I did. I originally read it as So I could implement |
||
|
||
|
||
# check for presence of _pyXX, skip if version is later, and prune parameter | ||
def check_version(test: str): | ||
python_version = re.search(r"(?<=_PY)\d*", test) | ||
|
@@ -332,8 +348,8 @@ def _parse_eval_file(test: str, content: str) -> tuple[list[Error], list[str], s | |
{ | ||
"lineno": lineno, | ||
"line": lineno, | ||
"Statement": Statement, | ||
"Stmt": Statement, | ||
"Statement": ColumnAgnosticStatement, | ||
"Stmt": ColumnAgnosticStatement, | ||
}, | ||
) | ||
except NameError: | ||
|
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.
Probably worth a comment explaining what this class is, and why we override
__eq__
and__hash__
(and what the semantics of this class are).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.
ended up reverting stuff and implementing a simple
__hash__
:)