Skip to content

feat: Hide outputs in the logs for path.exists method - #43

Merged
a-gorczew merged 1 commit into
mainfrom
log_path_logging
Aug 21, 2026
Merged

a-gorczew merged 1 commit into
mainfrom
log_path_logging

Conversation

@adrianlasota

Copy link
Copy Markdown
Contributor

This pull request updates the CustomPosixPath.exists() method to suppress logging output more robustly by using the DisableLogger context manager with optional parameters, depending on its constructor signature. It also adds comprehensive tests to verify this behavior.

Logging control improvements

  • Updated CustomPosixPath.exists() to use DisableLogger with the level parameter if supported, ensuring that logging output is properly suppressed during command execution. The method now dynamically checks for the presence of the level parameter in DisableLogger's constructor using inspect.signature.
  • Added DisableLogger to the imports in mfd_connect/pathlib/path.py to support the new logging control logic.

Testing enhancements

  • Added two unit tests to verify that CustomPosixPath.exists() uses DisableLogger with or without the level parameter, depending on the constructor signature. These tests use mocking to simulate different signatures and assert correct usage.
  • Added log_levels import to the test file to support the new tests.

@mfd-intel-bot

Copy link
Copy Markdown
Contributor

We don't publish DEVs .whl.
To build .whl, run 'pip install git+https://github.com/intel/mfd-connect@log_path_logging'

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates CustomPosixPath.exists() to suppress command logging output more robustly by wrapping the command execution in DisableLogger, optionally passing level=log_levels.OUT when that constructor parameter is supported, and adds unit tests to validate both code paths.

Changes:

  • Updated CustomPosixPath.exists() to conditionally pass level to DisableLogger based on inspect.signature(...).
  • Added unit tests covering DisableLogger() vs DisableLogger(level=...) usage in exists().
  • Updated imports to support the new logging-control behavior in both implementation and tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
mfd_connect/pathlib/path.py Wraps CustomPosixPath.exists() execution with DisableLogger, conditionally adding level support.
tests/unit/test_mfd_connect/test_pathlib/test_path.py Adds tests that mock inspect.signature and assert the correct DisableLogger invocation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mfd_connect/pathlib/path.py Outdated
@coveralls-official

coveralls-official Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 79.875% (+0.01%) from 79.864% — log_path_logging into main

Output doesn't matter for the user, check works with rc and "permission denied" in the output

Signed-off-by: Lasota, Adrian <adrian.lasota@intel.com>
@a-gorczew
a-gorczew merged commit 0c13e04 into main Aug 21, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants