Skip to content

Commit 9bfda18

Browse files
authored
Merge pull request #3 from AnshMNSoni/code_quality
fix the space and indentation issue leds in bad code quality
2 parents 9b4d2b3 + 88fb58c commit 9bfda18

File tree

18 files changed

+553
-554
lines changed

18 files changed

+553
-554
lines changed

.flake8

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
max-line-length = 100
3-
exclude =
3+
exclude =
44
.git,
55
__pycache__,
66
.venv,
@@ -10,9 +10,9 @@ exclude =
1010
*.egg-info,
1111
.pytest_cache,
1212
.mypy_cache
13-
ignore =
14-
E203, # whitespace before ':'
15-
W503, # line break before binary operator
16-
E501 # line too long (handled by max-line-length)
13+
ignore =
14+
E203,
15+
W503,
16+
E501
1717
per-file-ignores =
1818
__init__.py:F401,F403

.github/workflows/python.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ jobs:
2929
3030
- name: Run flake8
3131
run: |
32-
flake8 pystl/ --count --show-source --statistics
32+
flake8 pythonstl/ --count --show-source --statistics
3333
3434
- name: Run mypy
3535
run: |
36-
mypy pystl/ --ignore-missing-imports
36+
mypy pythonstl/ --ignore-missing-imports
3737
continue-on-error: true
3838

3939
- name: Run tests with coverage
4040
run: |
41-
pytest tests/ --cov=pystl --cov-report=xml --cov-report=term
41+
pytest tests/ --cov=pythonstl --cov-report=xml --cov-report=term
4242
4343
- name: Upload coverage reports
4444
uses: codecov/codecov-action@v3

pythonstl/core/base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@
1717
class ContainerBase(ABC, Generic[T]):
1818
"""
1919
Abstract base class for all STL-style containers.
20-
20+
2121
Provides common interface methods that all containers must implement.
2222
"""
23-
23+
2424
@abstractmethod
2525
def empty(self) -> bool:
2626
"""
2727
Check if the container is empty.
28-
28+
2929
Returns:
3030
bool: True if container is empty, False otherwise.
31-
31+
3232
Time Complexity:
3333
O(1)
3434
"""
3535
pass
36-
36+
3737
@abstractmethod
3838
def size(self) -> int:
3939
"""
4040
Get the number of elements in the container.
41-
41+
4242
Returns:
4343
int: Number of elements in the container.
44-
44+
4545
Time Complexity:
4646
O(1)
4747
"""

pythonstl/core/exceptions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class PySTLException(Exception):
1414
class EmptyContainerError(PySTLException):
1515
"""
1616
Exception raised when attempting to access elements from an empty container.
17-
17+
1818
This matches the behavior of C++ STL when accessing empty containers
1919
(e.g., calling top() on an empty stack).
2020
"""
21-
21+
2222
def __init__(self, container_type: str):
2323
self.container_type = container_type
2424
super().__init__(f"Cannot access element from empty {container_type}")
@@ -27,10 +27,10 @@ def __init__(self, container_type: str):
2727
class OutOfRangeError(PySTLException):
2828
"""
2929
Exception raised when accessing an invalid index or position.
30-
30+
3131
This matches C++ STL's std::out_of_range exception.
3232
"""
33-
33+
3434
def __init__(self, index: int, size: int):
3535
self.index = index
3636
self.size = size
@@ -40,10 +40,10 @@ def __init__(self, index: int, size: int):
4040
class KeyNotFoundError(PySTLException):
4141
"""
4242
Exception raised when a key is not found in an associative container.
43-
43+
4444
This matches C++ STL behavior when accessing non-existent keys in maps.
4545
"""
46-
46+
4747
def __init__(self, key):
4848
self.key = key
4949
super().__init__(f"Key '{key}' not found in container")

pythonstl/core/iterator.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
enabling both C++ STL-style iteration and Python iteration protocols.
66
"""
77

8-
from typing import TypeVar, Generic, List, Any
8+
from typing import TypeVar, Generic, List
99
from abc import ABC, abstractmethod
1010

1111
T = TypeVar('T')
@@ -14,15 +14,15 @@
1414
class Iterator(ABC, Generic[T]):
1515
"""
1616
Abstract base class for iterators.
17-
17+
1818
Provides the foundation for both forward and reverse iterators.
1919
"""
20-
20+
2121
@abstractmethod
2222
def __next__(self) -> T:
2323
"""Get the next element."""
2424
pass
25-
25+
2626
@abstractmethod
2727
def __iter__(self):
2828
"""Return the iterator itself."""
@@ -32,28 +32,28 @@ def __iter__(self):
3232
class VectorIterator(Iterator[T]):
3333
"""
3434
Forward iterator for vector.
35-
35+
3636
This iterator traverses the vector from beginning to end.
3737
"""
38-
38+
3939
def __init__(self, data: List[T], index: int = 0) -> None:
4040
"""
4141
Initialize vector iterator.
42-
42+
4343
Args:
4444
data: Reference to the vector's internal data
4545
index: Starting position
4646
"""
4747
self._data = data
4848
self._index = index
49-
49+
5050
def __next__(self) -> T:
5151
"""
5252
Get the next element.
53-
53+
5454
Returns:
5555
The next element in the vector.
56-
56+
5757
Raises:
5858
StopIteration: When iteration is complete.
5959
"""
@@ -62,7 +62,7 @@ def __next__(self) -> T:
6262
value = self._data[self._index]
6363
self._index += 1
6464
return value
65-
65+
6666
def __iter__(self):
6767
"""Return the iterator itself."""
6868
return self
@@ -71,14 +71,14 @@ def __iter__(self):
7171
class VectorReverseIterator(Iterator[T]):
7272
"""
7373
Reverse iterator for vector.
74-
74+
7575
This iterator traverses the vector from end to beginning.
7676
"""
77-
77+
7878
def __init__(self, data: List[T], index: int = -1) -> None:
7979
"""
8080
Initialize reverse vector iterator.
81-
81+
8282
Args:
8383
data: Reference to the vector's internal data
8484
index: Starting position (default: last element)
@@ -88,14 +88,14 @@ def __init__(self, data: List[T], index: int = -1) -> None:
8888
self._index = len(data) - 1
8989
else:
9090
self._index = index
91-
91+
9292
def __next__(self) -> T:
9393
"""
9494
Get the next element (in reverse order).
95-
95+
9696
Returns:
9797
The next element in reverse order.
98-
98+
9999
Raises:
100100
StopIteration: When iteration is complete.
101101
"""
@@ -104,7 +104,7 @@ def __next__(self) -> T:
104104
value = self._data[self._index]
105105
self._index -= 1
106106
return value
107-
107+
108108
def __iter__(self):
109109
"""Return the iterator itself."""
110110
return self
@@ -113,32 +113,32 @@ def __iter__(self):
113113
class SetIterator(Iterator[T]):
114114
"""
115115
Iterator for set.
116-
116+
117117
This iterator traverses the set elements.
118118
Note: Order is not guaranteed (matches Python set behavior).
119119
"""
120-
120+
121121
def __init__(self, data: set) -> None:
122122
"""
123123
Initialize set iterator.
124-
124+
125125
Args:
126126
data: Reference to the set's internal data
127127
"""
128128
self._iterator = iter(data)
129-
129+
130130
def __next__(self) -> T:
131131
"""
132132
Get the next element.
133-
133+
134134
Returns:
135135
The next element in the set.
136-
136+
137137
Raises:
138138
StopIteration: When iteration is complete.
139139
"""
140140
return next(self._iterator)
141-
141+
142142
def __iter__(self):
143143
"""Return the iterator itself."""
144144
return self
@@ -147,32 +147,32 @@ def __iter__(self):
147147
class MapIterator(Iterator):
148148
"""
149149
Iterator for map.
150-
150+
151151
This iterator traverses the map's key-value pairs.
152152
Returns tuples of (key, value).
153153
"""
154-
154+
155155
def __init__(self, data: dict) -> None:
156156
"""
157157
Initialize map iterator.
158-
158+
159159
Args:
160160
data: Reference to the map's internal data
161161
"""
162162
self._iterator = iter(data.items())
163-
163+
164164
def __next__(self):
165165
"""
166166
Get the next key-value pair.
167-
167+
168168
Returns:
169169
Tuple of (key, value).
170-
170+
171171
Raises:
172172
StopIteration: When iteration is complete.
173173
"""
174174
return next(self._iterator)
175-
175+
176176
def __iter__(self):
177177
"""Return the iterator itself."""
178178
return self

0 commit comments

Comments
 (0)