Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move MetaWarning classes into new cli module #142

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Pennycook
Copy link
Contributor

Related issues

Part of #36, #96.

The CLI is the least well-tested part of Code Base Investigator, because its legacy implementation lived outside of the codebasin/ package and was therefore difficult to test. Refactoring common CLI functionality into a dedicated module, using functions with well-defined interfaces, will make this functionality more reliable.

Proposed changes

  • Move Formatter, MetaWarning and WarningAggregator into a new cli module.
  • Add missing docstrings.
  • Add unit tests for Formatter, MetaWarning and WarningAggregator.

Moving them out of __main__.py will make it easier to re-use them across
different command-line interfaces, and may make them easier to test.

While moving them, I also added the missing docstrings.

Signed-off-by: John Pennycook <[email protected]>
Signed-off-by: John Pennycook <[email protected]>
Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook added the refactor Improvements to code structure label Dec 17, 2024
@Pennycook Pennycook added this to the 2.0.0 milestone Dec 17, 2024
Copy link
Contributor

@laserkelvin laserkelvin Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's just me, but the naming of this module doesn't seem to really fit its contents?

It's called cli.py but it contains logging stuff, and if we're moving things around, would it make sense to name it something that maps better? (log_utils.py?)

Otherwise, refactors and new tests look good to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I can see the confusion. I'll explain my logic, and you can tell me if it makes sense 😆.

The thinking behind this "cli" module was that it would contain things that were only useful for the user-facing command-line interface, but which might be shared across commands (e.g., the Formatter is currently used by both codebasin and cbicov).

I was basically looking for a way to separate things that we use to build the user-facing CLI from the modules and interfaces that we (eventually) want people to be able to use when importing the codebasin package into another script.

Maybe it would be better to have this as something like a cli package, containing a logging.py? Or an _internal package containing a logging.py? I'm definitely open to suggestions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improvements to code structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants