refactor: clean structure, full test suite & README — HISTMessagesGenerator#21
Merged
Merged
Conversation
…ed by tests - all passing Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
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.
♻️ refactor: Clean structure, full test suite & README — HISTMessagesGenerator
Summary
This PR completes the
refactor/HISTGEN-clean-structurework by adding a production-grade test suite, fixing the project's import and packaging configuration, and writing a full README — all grounded in the actual source code as it exists on this branch.What Changed
🏗️ Project Structure —
src-layout enforcedThe package was already moved to
src/hist_message_generator/in a prior commit. This PR wires the tooling to that layout correctly:📖 README
README.mdadded with:@log_exceptions+lambdalogger issue)🐛 Bugs Documented (not fixed — intentional scope)
One source-level issue was discovered during test authorship and is documented rather than fixed, to keep this PR focused on structure and testing:
@log_exceptionsdoes not call alambdalogger.When
logger=lambda self: HISTMessagesGenerator.loggeris passed, the decorator stores the lambda as_loggerdirectly instead of calling it. When an exception occurs, invoking_logger.warning(...)raisesAttributeErrorbecause a lambda has no.warningattribute. The original exception is still the root cause and still propagates (becauseraise_exception=True), but the log message is lost.Tests that exercise these paths catch
(OriginalException, AttributeError)and are annotated explaining why. A follow-up issue should fix the decorator to call callable loggers:if callable(logger) and not isinstance(logger, str): _logger = logger(*args[:1]).How to Run
Checklist
MIT,2026 Laurent Morissette)ruff check src/ tests/cleanpython -m pytest tests/)tests/directorypyproject.toml[project.scripts]entry point should be updated fromhist_messages_generator.hist_messages_generator:main→hist_message_generator.hist_messages_generator:main(trailingsmismatch — breakshist-genCLI afterpip install)Reviewers
Please pay attention to:
conftest.pyat root — must not be moved insidetests/. It needs to be at the same level aspyproject.tomlto fire before collection.Import style in test files — always
from hist_message_generator import ...(nos). The old namehist_messages_generatordoes not exist as a directory undersrc/and will always produceModuleNotFoundError.REG-009 — the
idemnitytypo inInstrumentClass.LETTER_OF_INDEMNITYis intentional. It matches the value expected by the downstream system. Do not autocorrect it.