fix: remove dead code and optimize cache cleanup#3
Merged
Conversation
- Remove unreachable if rate is None checks after get_currency_rate() (get_currency_rate always returns float or raises exception) - Change get_currency_rate return type from Optional[float] to float - Update docstring to reflect actual behavior (always returns float or raises) - Optimize cache cleanup: lazy cleanup only on overflow in set() - Remove cleanup_expired() call from get() method (check TTL per entry only) - Update tests to match new behavior - Fix test_cache_cleanup_triggered_on_set for new lazy cleanup logic - Fix test_convert_rate_none to test exception handling instead of None return Test coverage: 77.40% (above required 70%) Pylint: 10.00/10
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Исправление выявленных проблем из анализа проекта и оптимизация производительности кэша.
Изменения
Исправления
if rate is Noneпосле вызоваget_currency_rate()вcurrency_converter.pyget_currency_rate()сOptional[float]наfloatвcbr_parser.pyget_currency_rate()для соответствия фактическому поведениюОптимизации
get()теперь выполняется только для конкретной записи (O(1) вместо O(n))Тесты
Файлы изменений
src/currate/currency_converter.py- удален мертвый кодsrc/currate/cbr_parser.py- исправлена сигнатура и docstringsrc/currate/cache.py- оптимизирована очистка кэшаtests/test_cache_extended.py- обновлен тестtests/test_currency_converter_extended.py- обновлен тестCHANGELOG.md- обновлена документация измененийПроверка
Связанные задачи
Исправление проблем, выявленных в анализе проекта CurRate.
Note
Aligns
get_currency_rate()to always returnfloat, removes unreachableNonechecks, optimizes cache with lazy cleanup and per-key TTL checks, and updates tests/changelog accordingly.src/currate/cache.py): Lazy cleanup onset()only when capacity is hit; TTL checked per entry inget(); preserves LRU behavior.src/currate/cbr_parser.py):get_currency_rate()return type changed fromOptional[float]tofloat; docstring clarified (noNone, explicit exceptions).src/currate/currency_converter.py): Removed deadif rate is Nonebranches afterget_currency_rate(); error handling via exceptions only.Nonerate behavior and lazy cache cleanup (patcheddatetime, explicitcleanup_expired()where needed).CHANGELOG.mdupdated with fixes, performance notes, and test/quality metrics.Written by Cursor Bugbot for commit 2e2d0ff. This will update automatically on new commits. Configure here.