Skip to content

Commit

Permalink
[squash] Fix linter problems
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaTomasko committed Jan 24, 2024
1 parent bd26dc9 commit 55cf66c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion scaaml/capture/input_generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""Attack point generators and iterator."""

from scaaml.capture.input_generators.input_generators import balanced_generator, single_bunch, unrestricted_generator
from scaaml.capture.input_generators.attack_point_itarator import AttackPointIterator
from scaaml.capture.input_generators.attack_point_iterator import AttackPointIterator
9 changes: 6 additions & 3 deletions scaaml/capture/input_generators/attack_point_itarator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

class AttackPointIterator:
"""Attack point iterator class that iterates with different configs."""

def __init__(self, configuration) -> None:
"""Initialize a new iterator."""
self._attack_point_iterator_internal: AttackPointIteratorInternalBase
Expand Down Expand Up @@ -50,6 +51,7 @@ def __next__(self) -> namedtuple:

class AttackPointIteratorInternalBase(ABC):
"Attack point iterator abstract class."

@abstractmethod
def __len__(self) -> int:
"""Return the number of iterated elements.
Expand All @@ -65,10 +67,11 @@ def __next__(self) -> namedtuple:


class AttackPointIteratorInternalConstants(AttackPointIteratorInternalBase):
"""Attack point iterator class that iterates over a constent."""
"""Attack point iterator class that iterates over a constant."""

def __init__(self, name: str, values: List[List[int]]) -> None:
"""Initialize the constants to iterate."""
self._Valuestuple = namedtuple(typename=name, field_names="value")
self._ValuesTuple = namedtuple(typename=name, field_names="value")

Check failure on line 74 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / mypy

NamedTuple type as an attribute is not supported [misc]

Check failure on line 74 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.8)

Attribute name "_ValuesTuple" doesn't conform to '^_{0,2}[a-z][a-z0-9_]*$' pattern (invalid-name)

Check failure on line 74 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.9)

Attribute name "_ValuesTuple" doesn't conform to '^_{0,2}[a-z][a-z0-9_]*$' pattern (invalid-name)

Check failure on line 74 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.10)

Attribute name "_ValuesTuple" doesn't conform to '^_{0,2}[a-z][a-z0-9_]*$' pattern (invalid-name)

Check failure on line 74 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.11)

Attribute name "_ValuesTuple" doesn't conform to '^_{0,2}[a-z][a-z0-9_]*$' pattern (invalid-name)
self._values = values
self._index = 0

Expand All @@ -80,7 +83,7 @@ def __iter__(self):

def __next__(self) -> namedtuple:

Check failure on line 84 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / mypy

Function "collections.namedtuple" is not valid as a type [valid-type]

Check failure on line 84 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / mypy

Perhaps you need "Callable[...]" or a callback protocol?
if self._index < self.__len__():
tuple = self._Valuestuple(self._values[self._index])
tuple = self._ValuesTuple(self._values[self._index])

Check failure on line 86 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.8)

Redefining built-in 'tuple' (redefined-builtin)

Check failure on line 86 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.9)

Redefining built-in 'tuple' (redefined-builtin)

Check failure on line 86 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.10)

Redefining built-in 'tuple' (redefined-builtin)

Check failure on line 86 in scaaml/capture/input_generators/attack_point_itarator.py

View workflow job for this annotation

GitHub Actions / pylint (3.11)

Redefining built-in 'tuple' (redefined-builtin)
self._index += 1
return tuple
else:
Expand Down
17 changes: 9 additions & 8 deletions tests/capture/input_generators/test_attack_point_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

def test_attack_point_itarattor_no_legal_operation():
input = {
"operation": "NONE",
"name": "key",
"operation":
"NONE",
"name":
"key",
"values": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]
}
Expand All @@ -18,8 +20,10 @@ def test_attack_point_itarattor_no_legal_operation():

def test_attack_point_iterator_constants():
input = {
"operation": "constants",
"name": "key",
"operation":
"constants",
"name":
"key",
"values": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]
}
Expand All @@ -31,10 +35,7 @@ def test_attack_point_iterator_constants():


def test_attack_point_iterator_constants_no_values():
input = {
"operation": "constants",
"name": "key"
}
input = {"operation": "constants", "name": "key"}
output = []
with pytest.raises(KeyError):
AttackPointIterator(input)

0 comments on commit 55cf66c

Please sign in to comment.