Skip to content

Add error behavior per check#825

Open
languitar wants to merge 2 commits into
mainfrom
feature/error-behavior
Open

Add error behavior per check#825
languitar wants to merge 2 commits into
mainfrom
feature/error-behavior

Conversation

@languitar

Copy link
Copy Markdown
Owner

Fixes #814

@codecov

codecov Bot commented May 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.12281% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.91%. Comparing base (1428aa9) to head (5dc8108).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/autosuspend/__init__.py 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #825      +/-   ##
==========================================
- Coverage   95.93%   95.91%   -0.03%     
==========================================
  Files          21       21              
  Lines        1502     1517      +15     
  Branches      129      130       +1     
==========================================
+ Hits         1441     1455      +14     
  Misses         46       46              
- Partials       15       16       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@languitar languitar force-pushed the feature/error-behavior branch 3 times, most recently from 21c7a18 to 4d71260 Compare May 11, 2026 20:29
The name parameter is removed from Check.__init__, Check.create, and all
concrete check implementations. Logging now uses the class name via
logger_by_class_instance. This is a breaking change preparing for the
ConfiguredCheck wrapper which will hold name and error behavior.

BREAKING CHANGE: Check.create no longer accepts a name argument; subclasses
must update their create() and __init__ signatures accordingly.
@languitar languitar force-pushed the feature/error-behavior branch 6 times, most recently from 651b2b0 to 5a84322 Compare May 11, 2026 20:46
@languitar languitar requested a review from Copilot May 11, 2026 20:48
@languitar languitar marked this pull request as ready for review May 11, 2026 20:49

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 adds a per-check configuration option to control how temporary check failures (raising TemporaryCheckError) influence suspension decisions, addressing issue #814.

Changes:

  • Introduces ErrorBehavior and a ConfiguredCheck wrapper to attach configured name + error handling policy to each check.
  • Updates execution logic to optionally treat temporary errors as inactive (ignore) instead of active (active).
  • Refactors check factories/constructors and updates tests + documentation to match the new configuration and instantiation model.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/autosuspend/__init__.py Parses error_behavior, wraps checks in ConfiguredCheck, and updates check/wakeup execution to use configured error handling.
src/autosuspend/checks/__init__.py Adds ErrorBehavior + ConfiguredCheck and changes the check factory/init interfaces.
src/autosuspend/checks/{command,ical,json,kodi,linux,logs,mpd,smb,stub,systemd,util,xorg,xpath}.py Adapts built-in checks to the updated create()/__init__() signatures (removal of name parameter).
tests/test_autosuspend.py Updates unit tests to use ConfiguredCheck and adds coverage for ignore-vs-active error behavior during execution.
tests/test_checks*.py, tests/__init__.py Updates tests to the new constructor/factory signatures and removes name-related expectations.
doc/source/configuration_file.inc Documents the new error_behavior option and shows it in the example config.
setup.cfg Enables mypy’s exhaustive-match error code.

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

Comment thread src/autosuspend/__init__.py
Comment thread src/autosuspend/__init__.py
Comment thread src/autosuspend/checks/__init__.py
Comment on lines +76 to +77
def __init__(self) -> None:
self.logger = logger_by_class_instance(self)
raise ConfigurationError(
"Check %s is not a correct %s instance", check, target_class.__name__
)
_logger.debug("Created check instance %s with options %s", check, check.options())
Comment thread doc/source/configuration_file.inc Outdated
@languitar languitar force-pushed the feature/error-behavior branch from 24bc3b5 to f066f12 Compare May 11, 2026 20:58
Adds a well-known option to each activity check for defining how
temporary check errors should be treated: ignore or treat the system as
active.

For the implementation: adds an ErrorBehavior enum (ACTIVE/IGNORE) and
ConfiguredCheck dataclass to checks/__init__.py. Wire ConfiguredCheck
through set_up_checks, _set_up_single_check, execute_checks,
execute_wakeups, Processor, and configure_processor. The error_behavior
config option controls whether temporary check errors prevent suspension
(ACTIVE) or are silently ignored (IGNORE, default).

Fixes: #814
@languitar languitar force-pushed the feature/error-behavior branch from f066f12 to 5dc8108 Compare May 11, 2026 21:00
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.

[feature] Option to ignore errors from checks

2 participants