Skip to content

Commit 0c1594a

Browse files
fix: Remove legacy backward compatibility code and comments (#37)
Removed backward compatibility code sections and comments from the codebase as the tool now has a single stable interface with no historic dependencies. Changes: - bibtex_parser.py: Removed unused wrapper methods _extract_authors() and _get_field() that were marked for backward compatibility - bibtex_parser.py: Updated reference to use _get_field_safely() directly - cache.py: Removed "BACKWARD COMPATIBILITY" section headers and comments - cache.py: Updated docstrings to remove backward compatibility language while maintaining current functionality - cache.py: Changed misleading comments to accurately describe the current purpose of methods All tests pass and functionality is preserved. These methods are actively used by the codebase and have been retained with updated documentation. Fixes #13 Co-authored-by: florath-ai-assistant[bot] <Andreas.Florath@telekom.de>
1 parent ecd0b33 commit 0c1594a

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

src/aletheia_probe/bibtex_parser.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _extract_journal_name(entry: Entry) -> str | None:
220220
journal_fields = ["journal", "journaltitle"]
221221

222222
for field in journal_fields:
223-
journal_name = BibtexParser._get_field(entry, field)
223+
journal_name = BibtexParser._get_field_safely(entry, field)
224224
if journal_name:
225225
return journal_name
226226

@@ -298,15 +298,6 @@ def _extract_authors_safely(entry: Entry) -> str | None:
298298
detail_logger.debug(f"Error extracting authors: {e}")
299299
return None
300300

301-
@staticmethod
302-
def _extract_authors(entry: Entry) -> str | None:
303-
"""Extract author information from a BibTeX entry.
304-
305-
This is the original method, kept for backward compatibility.
306-
New code should use _extract_authors_safely.
307-
"""
308-
return BibtexParser._extract_authors_safely(entry)
309-
310301
@staticmethod
311302
def _get_field_safely(entry: Entry, field_name: str) -> str | None:
312303
"""Get a field value from a BibTeX entry with error handling.
@@ -346,12 +337,3 @@ def _get_field_safely(entry: Entry, field_name: str) -> str | None:
346337
except Exception as e:
347338
detail_logger.debug(f"Error getting field '{field_name}': {e}")
348339
return None
349-
350-
@staticmethod
351-
def _get_field(entry: Entry, field_name: str) -> str | None:
352-
"""Get a field value from a BibTeX entry.
353-
354-
This is the original method, kept for backward compatibility.
355-
New code should use _get_field_safely.
356-
"""
357-
return BibtexParser._get_field_safely(entry, field_name)

src/aletheia_probe/cache.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def search_journals(
484484
# Get URLs from pre-fetched data
485485
journal_dict["urls"] = urls_by_journal.get(journal_id, [])
486486

487-
# Get source-specific data for backward compatibility
487+
# Get source-specific data when filtering by source
488488
if source_name:
489489
source_cursor = conn.execute(
490490
"""
@@ -499,7 +499,7 @@ def search_journals(
499499

500500
source_data = source_cursor.fetchall()
501501
if source_data:
502-
# Add backward compatibility fields
502+
# Add convenience aliases for common fields
503503
journal_dict["journal_name"] = journal_dict["display_name"]
504504
journal_dict["list_type"] = source_data[0][0] # assessment
505505

@@ -571,7 +571,6 @@ def find_conflicts(self) -> list[dict[str, Any]]:
571571

572572
return [dict(row) for row in cursor.fetchall()]
573573

574-
# Backward compatibility methods
575574
def cache_assessment_result(
576575
self,
577576
query_hash: str,
@@ -668,9 +667,6 @@ def get_source_last_updated(self, source_name: str) -> datetime | None:
668667
return datetime.fromisoformat(row[0])
669668
return None
670669

671-
# ===== BACKWARD COMPATIBILITY METHODS =====
672-
# These methods provide compatibility with the old CacheManager interface
673-
674670
def add_journal_list_entry(
675671
self,
676672
source_name: str,
@@ -683,9 +679,9 @@ def add_journal_list_entry(
683679
metadata: dict[str, Any] | None = None,
684680
) -> None:
685681
"""
686-
Backward compatibility method for add_journal_list_entry.
682+
Add a journal entry using list-based nomenclature.
687683
688-
Maps the old interface to the new normalized add_journal_entry method.
684+
Maps list-based parameters (list_type) to assessment-based parameters.
689685
"""
690686
# Register the data source if not exists (use generic "mixed" type to avoid conflicts)
691687
with sqlite3.connect(self.db_path) as conn:
@@ -854,15 +850,15 @@ def get_cached_value(self, key: str) -> str | None:
854850

855851
def get_source_stats(self) -> dict[str, dict[str, Any]]:
856852
"""
857-
Get statistics for all data sources (backward compatibility).
853+
Get statistics for all data sources.
858854
859855
Returns:
860-
Dictionary with source statistics in old format
856+
Dictionary with source statistics
861857
"""
862-
# Get the new statistics format
858+
# Get the base statistics
863859
stats = self.get_source_statistics()
864860

865-
# Convert to old format expected by tests
861+
# Convert to structured format
866862
result = {}
867863
for source_name, source_stats in stats.items():
868864
result[source_name] = {

0 commit comments

Comments
 (0)