Skip to content

Commit

Permalink
fix(CVSS2, CVSS3, CVSS4): 🩹 remove type hints from magic methods
Browse files Browse the repository at this point in the history
Removed type hints from the __eq__ and __hash__ magic methods in CVSS2, CVSS3 and CVSS4 classes for better compatibility with < Python3.5 versions
  • Loading branch information
fqlenos committed Sep 15, 2024
1 parent 45bf9e0 commit 30c8dae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cvss/cvss2.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ def add_metric_to_data(metric):

return data

def __hash__(self) -> int:
def __hash__(self):
return hash(self.clean_vector())

def __eq__(self, o) -> bool:
def __eq__(self, o):
if isinstance(o, CVSS2):
return self.clean_vector() == o.clean_vector()
return False
4 changes: 2 additions & 2 deletions cvss/cvss3.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,10 @@ def add_metric_to_data(metric):
data = OrderedDict(sorted(data.items()))
return data

def __hash__(self) -> int:
def __hash__(self):
return hash(self.clean_vector())

def __eq__(self, o) -> bool:
def __eq__(self, o):
if isinstance(o, CVSS3):
return self.clean_vector() == o.clean_vector()
return False
4 changes: 2 additions & 2 deletions cvss/cvss4.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,10 @@ def add_metric_to_data(metric):
data = OrderedDict(sorted(data.items()))
return data

def __hash__(self) -> int:
def __hash__(self):
return hash(self.clean_vector())

def __eq__(self, o) -> bool:
def __eq__(self, o):
if isinstance(o, CVSS4):
return self.clean_vector() == o.clean_vector()
return False

0 comments on commit 30c8dae

Please sign in to comment.