diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af79ff62..e804b53f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: - id: buildifier - id: buildifier-lint - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.1 + rev: v1.11.0 hooks: - id: mypy additional_dependencies: [types-requests==2.31.0.20240218] diff --git a/py_proto/proto_import.py b/py_proto/proto_import.py index 3990d43f..7fb86e87 100644 --- a/py_proto/proto_import.py +++ b/py_proto/proto_import.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Any, Iterator, Optional from py_proto.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff from py_proto.proto_string_literal import ProtoStringLiteral @@ -26,19 +26,21 @@ def __eq__(self, other) -> bool: and (hasattr(other, "public") and self.public == other.public) ) + def __iter__(self) -> Iterator: + return iter( + { + "path": self.path.serialize(), + "weak": self.weak, + "public": self.public, + } + ) + def __str__(self) -> str: return f"" def __repr__(self) -> str: return str(self) - def __dict__(self): - return { - "path": self.path.serialize(), - "weak": self.weak, - "public": self.public, - } - def normalize(self) -> "ProtoImport": return self diff --git a/py_proto/proto_syntax.py b/py_proto/proto_syntax.py index dd1d7f00..1e823ce5 100644 --- a/py_proto/proto_syntax.py +++ b/py_proto/proto_syntax.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import Optional +from typing import Any, Iterator, Optional from py_proto.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff from py_proto.proto_string_literal import ProtoStringLiteral @@ -23,15 +23,15 @@ def __init__(self, syntax: ProtoStringLiteral, *args, **kwargs): def __eq__(self, other) -> bool: return self.syntax == other.syntax + def __iter__(self) -> Iterator: + return iter({"syntax": self.syntax.serialize()}) + def __str__(self) -> str: return f"" def __repr__(self) -> str: return str(self) - def __dict__(self): - return {"syntax": self.syntax.serialize()} - def normalize(self) -> "ProtoSyntax": return self