Skip to content

Ref #51 -- Resolve sentry_monitor_config type ambigutity#56

Merged
codingjoe merged 2 commits into
mainfrom
issues/51/type
May 27, 2026
Merged

Ref #51 -- Resolve sentry_monitor_config type ambigutity#56
codingjoe merged 2 commits into
mainfrom
issues/51/type

Conversation

@codingjoe
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 27, 2026 10:13
@codingjoe codingjoe self-assigned this May 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.82%. Comparing base (64b2891) to head (8a17a65).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #56      +/-   ##
==========================================
- Coverage   98.85%   98.82%   -0.03%     
==========================================
  Files           6        6              
  Lines         174      170       -4     
==========================================
- Hits          172      168       -4     
  Misses          2        2              

☔ 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.

Copy link
Copy Markdown

Copilot AI left a comment

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 (Ref #51) updates how sentry_monitor_config is represented and forwarded in the cron() decorator, aiming to eliminate ambiguity between “unset/default”, “custom config”, and “disabled” Sentry monitoring.

Changes:

  • Introduces an UNSET sentinel to distinguish “argument not provided” from “provided but falsy”.
  • Adjusts cron() and Sentry integration typing/behavior around sentry_monitor_config.
  • Updates docs and tests to reflect the new “falsy disables” semantics.

Reviewed changes

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

File Description
crontask/__init__.py Adds UNSET sentinel and changes cron()’s sentry_monitor_config typing and forwarding behavior.
crontask/contrib/sentry.py Changes monitor_cron_task() signature for sentry_monitor_config.
README.md Updates usage guidance/examples for disabling Sentry monitoring.
tests/test_tasks.py Relaxes assertion around default forwarded sentry_monitor_config.
Comments suppressed due to low confidence (1)

crontask/contrib/sentry.py:84

  • monitor_cron_task() now requires sentry_monitor_config to be a dict, but the function still treats it as optional via sentry_monitor_config or trigger_to_monitor_config(trigger), and existing tests call it with None. This should either keep the | None in the signature (and document that None triggers auto-detection) or update callers/tests and the internal logic to remove None support consistently.
def monitor_cron_task(
    task: Task,
    trigger: BaseTrigger,
    sentry_monitor_config: dict[str, dict[str, str | int] | str],
) -> Task:
    """
    Wrap the task function in a Sentry monitor for a suitable trigger.

    You don't need to create the monitor in advance since
    the Sentry monitor configuration is upserted on each task execution.
    If the trigger is not supported, the task is returned unchanged.
    """
    try:
        from sentry_sdk import monitor
    except ImportError:
        return task
    else:
        if monitor_config := sentry_monitor_config or trigger_to_monitor_config(
            trigger
        ):

Comment thread crontask/__init__.py
Comment thread crontask/__init__.py
Comment thread tests/test_tasks.py Outdated
Comment thread README.md
@codingjoe codingjoe merged commit fbe0c7d into main May 27, 2026
14 of 15 checks passed
@codingjoe codingjoe deleted the issues/51/type branch May 27, 2026 10:43
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.

2 participants