Skip to content

Make sunset warning handling configurable#57

Merged
Michel Edkrantz (MichelEdkrantz) merged 1 commit intomasterfrom
configurable-sunset-handler
Feb 20, 2026
Merged

Make sunset warning handling configurable#57
Michel Edkrantz (MichelEdkrantz) merged 1 commit intomasterfrom
configurable-sunset-handler

Conversation

@MichelEdkrantz
Copy link
Copy Markdown
Member

Summary

  • Add SunsetHandler = Callable[[datetime, str, str], None] type alias
  • Add default_sunset_handler(threshold_days=14) factory that returns the standard logging behaviour with a configurable escalation threshold
  • handle_sunset, create_session, BaseApiClient, and BaseAsyncApiClient all accept an optional sunset_handler parameter — pass None to disable, a factory call to adjust the threshold, or any callable for fully custom behaviour
  • SunsetHandler and default_sunset_handler re-exported from the top-level kognic.auth package

Usage

from kognic.auth import default_sunset_handler
from kognic.auth.requests import BaseApiClient

# Adjust threshold
client = BaseApiClient(sunset_handler=default_sunset_handler(threshold_days=30))

# Disable entirely
client = BaseApiClient(sunset_handler=None)

# Custom handler (e.g. raise instead of log)
def strict(sunset_date, method, url):
    raise DeprecationWarning(f"Deprecated endpoint: {method} {url}")

client = BaseApiClient(sunset_handler=strict)

Test plan

  • All 212 existing tests pass (uv run pytest)
  • Ruff check and format pass with no changes

🤖 Generated with Claude Code

Add a SunsetHandler type alias and a default_sunset_handler(threshold_days=14)
factory so callers can customise the threshold, silence the handler by passing
None, or replace it entirely with a custom callable on BaseApiClient,
BaseAsyncApiClient, and create_session.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MichelEdkrantz Michel Edkrantz (MichelEdkrantz) merged commit 0b1b929 into master Feb 20, 2026
10 checks passed
@MichelEdkrantz Michel Edkrantz (MichelEdkrantz) deleted the configurable-sunset-handler branch February 20, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant