Skip to content

Commit 509e2e2

Browse files
committed
[release] v0.4.0
1 parent 5d6bb7f commit 509e2e2

15 files changed

Lines changed: 363 additions & 346 deletions

File tree

docs/source/changelog.rst

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ Unreleased
1818
Added
1919
-----
2020

21-
- **[feat:typo] Smart typo detection system** - Added comprehensive typo detection infrastructure with TypoDetector, ScopeAnalyzer, and PythonStyleFormatter classes
22-
- **[feat:typo] Levenshtein Distance algorithm** - Implemented string similarity algorithm for basic typo detection with optimized space complexity
23-
- **[feat:typo] Python 3.11+ style error messages** - Added formatted error messages with file location, source highlighting, and typo suggestions
24-
- **[feat:typo] Semantic similarity scoring** - Enhanced confidence calculation with prefix/suffix matching and contextual relevance analysis
25-
- **[feat:typo] Integration with IsRequiredConstraint** - Automatic typo suggestions when validation rules fail to find required elements
26-
- **[feat:ux] Enhanced error reporting with numbered messages** - Added numbered error messages (1., 2., 3.) for better readability
27-
- **[feat:ux] User-visible typo suggestions** - Typo suggestions now appear in user output instead of debug logs only
28-
- **[feat:ux] Compact Russian typo format** - Created user-friendly Russian format for typo suggestions with proper indentation
21+
- *...*
2922

3023

3124
Changed
@@ -49,10 +42,7 @@ Removed
4942
Fixed
5043
-----
5144

52-
- **[Critical Bug]** Fixed scope validation bug where selectors were not receiving proper scope configuration from the factory, causing rules to search in wrong scopes or ignore scope restrictions entirely.
53-
- **[Scope Logic]** Improved global scope handling for different selector types: assignments now only search at module level, while function calls include ``if __name__ == "__main__"`` blocks.
54-
- **[fix:typo] Improved target type inference** - Enhanced logic for determining whether to search for assignments, functions, or classes based on naming patterns
55-
- **[fix:typo] Enhanced confidence scoring** - Improved similarity scoring algorithm with semantic context awareness for better typo suggestions
45+
- *...*
5646

5747

5848
Security
@@ -62,6 +52,32 @@ Security
6252

6353

6454

55+
v0.4.0 - 2025-08-06
56+
===================
57+
58+
Added
59+
-----
60+
61+
- **[feat:typo] Smart typo detection system** - Added comprehensive typo detection infrastructure with TypoDetector, ScopeAnalyzer, and PythonStyleFormatter classes
62+
- **[feat:typo] Levenshtein Distance algorithm** - Implemented string similarity algorithm for basic typo detection with optimized space complexity
63+
- **[feat:typo] Python 3.11+ style error messages** - Added formatted error messages with file location, source highlighting, and typo suggestions
64+
- **[feat:typo] Semantic similarity scoring** - Enhanced confidence calculation with prefix/suffix matching and contextual relevance analysis
65+
- **[feat:typo] Integration with IsRequiredConstraint** - Automatic typo suggestions when validation rules fail to find required elements
66+
- **[feat:ux] Enhanced error reporting with numbered messages** - Added numbered error messages (1., 2., 3.) for better readability
67+
- **[feat:ux] User-visible typo suggestions** - Typo suggestions now appear in user output instead of debug logs only
68+
- **[feat:ux] Compact Russian typo format** - Created user-friendly Russian format for typo suggestions with proper indentation
69+
70+
71+
Fixed
72+
-----
73+
74+
- **[Critical Bug]** Fixed scope validation bug where selectors were not receiving proper scope configuration from the factory, causing rules to search in wrong scopes or ignore scope restrictions entirely.
75+
- **[Scope Logic]** Improved global scope handling for different selector types: assignments now only search at module level, while function calls include ``if __name__ == "__main__"`` blocks.
76+
- **[fix:typo] Improved target type inference** - Enhanced logic for determining whether to search for assignments, functions, or classes based on naming patterns
77+
- **[fix:typo] Enhanced confidence scoring** - Improved similarity scoring algorithm with semantic context awareness for better typo suggestions
78+
79+
80+
6581
v0.3.0 - 2025-07-19
6682
===================
6783

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
1010
# ==============================================================================
1111
[project]
1212
name = "python-code-validator"
13-
version = "0.3.0"
13+
version = "0.4.0"
1414
description = "A flexible, AST-based framework for static validation of Python code using declarative JSON rules."
1515
keywords = ["validation", "linter", "static analysis", "testing", "education", "ast"]
1616
authors = [{ name = "Qu1nel", email = "covach.qn@gmail.com" }]

src/code_validator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@
5454
"RuleParsingError",
5555
]
5656

57-
__version__ = "0.3.0"
57+
__version__ = "0.4.0"

src/code_validator/components/typo_detection/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
analyzes similar names in the same scope and provides helpful suggestions.
66
77
Example:
8-
Instead of just "Required attribute 'self.speed' not found",
8+
Instead of just "Required attribute 'self.speed' not found",
99
users get "Did you mean 'self.speed' instead of 'self.sped'?"
1010
1111
Classes:
1212
TypoDetector: Main detector class for analyzing failed searches
13-
ScopeAnalyzer: Extracts names from specific AST scopes
13+
ScopeAnalyzer: Extracts names from specific AST scopes
1414
PythonStyleFormatter: Formats suggestions like Python 3.11+ errors
1515
"""
1616

1717
from .detector import TypoDetector
18-
from .scope_analyzer import ScopeAnalyzer
1918
from .formatters import PythonStyleFormatter
19+
from .scope_analyzer import ScopeAnalyzer
2020

2121
__all__ = [
2222
"TypoDetector",
23-
"ScopeAnalyzer",
23+
"ScopeAnalyzer",
2424
"PythonStyleFormatter",
25-
]
25+
]

src/code_validator/components/typo_detection/algorithms.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313

1414
class SimilarityAlgorithm(Protocol):
1515
"""Protocol for string similarity algorithms."""
16-
16+
1717
def distance(self, s1: str, s2: str) -> int:
1818
"""Calculate distance between two strings.
19-
19+
2020
Args:
2121
s1: First string
2222
s2: Second string
23-
23+
2424
Returns:
2525
Distance value (lower = more similar)
2626
"""
2727
...
28-
28+
2929
def similarity(self, s1: str, s2: str) -> float:
3030
"""Calculate similarity score between two strings.
31-
31+
3232
Args:
3333
s1: First string
3434
s2: Second string
35-
35+
3636
Returns:
3737
Similarity score from 0.0 (no similarity) to 1.0 (identical)
3838
"""
@@ -41,77 +41,77 @@ def similarity(self, s1: str, s2: str) -> float:
4141

4242
class LevenshteinDistance:
4343
"""Levenshtein distance algorithm for measuring string similarity.
44-
45-
Calculates the minimum number of single-character edits (insertions,
44+
45+
Calculates the minimum number of single-character edits (insertions,
4646
deletions, or substitutions) required to change one string into another.
47-
47+
4848
Examples:
4949
>>> algo = LevenshteinDistance()
5050
>>> algo.distance("speed", "sped")
5151
1
52-
>>> algo.similarity("speed", "sped")
52+
>>> algo.similarity("speed", "sped")
5353
0.8
5454
"""
55-
55+
5656
def distance(self, s1: str, s2: str) -> int:
5757
"""Calculate Levenshtein distance between two strings.
58-
58+
5959
Uses dynamic programming approach with O(n*m) time complexity
6060
and O(min(n,m)) space complexity optimization.
61-
61+
6262
Args:
6363
s1: First string
6464
s2: Second string
65-
65+
6666
Returns:
6767
Minimum number of edits needed to transform s1 into s2
6868
"""
6969
if not s1:
7070
return len(s2)
7171
if not s2:
7272
return len(s1)
73-
73+
7474
# Ensure s1 is the shorter string for space optimization
7575
if len(s1) > len(s2):
7676
s1, s2 = s2, s1
77-
77+
7878
# Use only two rows instead of full matrix
7979
prev_row = list(range(len(s1) + 1))
8080
curr_row = [0] * (len(s1) + 1)
81-
81+
8282
for i in range(1, len(s2) + 1):
8383
curr_row[0] = i
84-
84+
8585
for j in range(1, len(s1) + 1):
8686
if s2[i - 1] == s1[j - 1]:
8787
curr_row[j] = prev_row[j - 1] # No operation needed
8888
else:
8989
curr_row[j] = 1 + min(
90-
prev_row[j], # Deletion
90+
prev_row[j], # Deletion
9191
curr_row[j - 1], # Insertion
92-
prev_row[j - 1] # Substitution
92+
prev_row[j - 1], # Substitution
9393
)
94-
94+
9595
prev_row, curr_row = curr_row, prev_row
96-
96+
9797
return prev_row[len(s1)]
98-
98+
9999
def similarity(self, s1: str, s2: str) -> float:
100100
"""Calculate similarity score based on Levenshtein distance.
101-
101+
102102
Args:
103103
s1: First string
104104
s2: Second string
105-
105+
106106
Returns:
107107
Similarity score from 0.0 to 1.0, where 1.0 means identical strings
108108
"""
109109
if not s1 and not s2:
110110
return 1.0
111-
111+
112112
max_len = max(len(s1), len(s2))
113113
if max_len == 0:
114114
return 1.0
115-
115+
116116
distance = self.distance(s1, s2)
117-
return 1.0 - (distance / max_len)
117+
return 1.0 - (distance / max_len)

0 commit comments

Comments
 (0)