Typing stubs for croniter

6.2.2.20260402 · active · verified Mon Apr 06

types-croniter is a type stub package from the `typeshed` project, providing external type annotations for the `croniter` library. It enables static analysis tools like MyPy and Pyright to perform type checking on code that uses `croniter`, improving code quality and catching potential type-related errors before runtime. The current version, 6.2.2.20260402, is designed to provide accurate annotations for `croniter==6.2.2`. These packages are part of the `typeshed` project and are released frequently, often daily, through `typeshed`'s automated processes.

Warnings

Install

Imports

Quickstart

This example demonstrates basic usage of the `croniter` library with type hints. When `types-croniter` is installed, a static type checker like MyPy can use these stubs to validate the types passed to and returned by `croniter`'s functions and methods, catching potential type errors during development.

from datetime import datetime
from croniter import croniter

# types-croniter provides static type checking for the 'croniter' library.
# Install it (pip install types-croniter) to enable your type checker (e.g., MyPy)
# to validate the usage of croniter objects and methods.

def schedule_info(cron_expression: str, start_from: datetime) -> None:
    """
    Calculates and prints the next two scheduled times based on a cron expression.
    Type hints here are validated by types-croniter if installed.
    """
    cron_iterator: croniter = croniter(cron_expression, start_from)

    print(f"Cron expression: '{cron_expression}'")
    print(f"Starting from: {start_from}")
    print(f"Next occurrence: {cron_iterator.get_next(datetime)}")
    print(f"Second next occurrence: {cron_iterator.get_next(datetime)}")

if __name__ == "__main__":
    current_time = datetime(2026, 4, 6, 10, 30)
    schedule_info('0 0 * * *', current_time) # Daily at midnight
    print("-" * 20)
    schedule_info('*/15 * * * *', current_time) # Every 15 minutes

view raw JSON →