diff options
| author | Adam Janovsky | 2023-04-14 20:39:27 +0200 |
|---|---|---|
| committer | Adam Janovsky | 2023-04-14 20:39:27 +0200 |
| commit | ec664404af0c2497d8b5c88fadb2df9c7380738b (patch) | |
| tree | ea9957e61878b064bc0392a0a79fa2945f9bf022 /src | |
| parent | 286a34cbdd5c81ba20b865c3c5674b61032913a2 (diff) | |
| download | sec-certs-ec664404af0c2497d8b5c88fadb2df9c7380738b.tar.gz sec-certs-ec664404af0c2497d8b5c88fadb2df9c7380738b.tar.zst sec-certs-ec664404af0c2497d8b5c88fadb2df9c7380738b.zip | |
fix cpe and cpe tests
Diffstat (limited to 'src')
| -rw-r--r-- | src/sec_certs/sample/cpe.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/sec_certs/sample/cpe.py b/src/sec_certs/sample/cpe.py index cdbeb239..61422330 100644 --- a/src/sec_certs/sample/cpe.py +++ b/src/sec_certs/sample/cpe.py @@ -107,7 +107,6 @@ class CPE(PandasSerializableType, ComplexSerializableType): __slots__ = ["cpe_id", "uri", "version", "vendor", "item_name", "title"] pandas_columns: ClassVar[list[str]] = [ - "cpe_id", "uri", "vendor", "item_name", @@ -131,6 +130,14 @@ class CPE(PandasSerializableType, ComplexSerializableType): self.version = self.normalize_version(" ".join(splitted[5].split("_"))) self.title = title + # We cannot use frozen=True. It does not work with __slots__ prior to Python 3.10 dataclasses + # Hence we manually provide __hash__ and __eq__ despite not guaranteeing immutability + def __hash__(self) -> int: + return hash(self.uri) + + def __eq__(self, other: object) -> bool: + return isinstance(other, self.__class__) and self.uri == other.uri + def __lt__(self, other: CPE) -> bool: return self.uri < other.uri @@ -167,11 +174,3 @@ class CPE(PandasSerializableType, ComplexSerializableType): @property def pandas_tuple(self) -> tuple: return self.uri, self.vendor, self.item_name, self.version, self.title - - # We cannot use frozen=True. It does not work with __slots__ prior to Python 3.10 dataclasses - # Hence we manually provide __hash__ and __eq__ despite not guaranteeing immutability - def __hash__(self) -> int: - return hash(self.uri) - - def __eq__(self, other: object) -> bool: - return isinstance(other, self.__class__) and self.uri == other.uri |
