{"library":"types-croniter","title":"Typing stubs for croniter","description":"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.","status":"active","version":"6.2.2.20260402","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","type hints","croniter","typeshed"],"install":[{"cmd":"pip install types-croniter","lang":"bash","label":"Install types-croniter"}],"dependencies":[{"reason":"`types-croniter` provides type hints for the `croniter` library. For runtime functionality and effective type checking, `croniter` must be installed separately alongside `types-croniter`.","package":"croniter","optional":false}],"imports":[{"note":"You do not directly import from `types_croniter`. Type stubs are automatically discovered by type checkers (e.g., MyPy, Pyright) when the actual `croniter` library is imported.","symbol":"croniter","correct":"from croniter import croniter"}],"quickstart":{"code":"from datetime import datetime\nfrom croniter import croniter\n\n# types-croniter provides static type checking for the 'croniter' library.\n# Install it (pip install types-croniter) to enable your type checker (e.g., MyPy)\n# to validate the usage of croniter objects and methods.\n\ndef schedule_info(cron_expression: str, start_from: datetime) -> None:\n    \"\"\"\n    Calculates and prints the next two scheduled times based on a cron expression.\n    Type hints here are validated by types-croniter if installed.\n    \"\"\"\n    cron_iterator: croniter = croniter(cron_expression, start_from)\n\n    print(f\"Cron expression: '{cron_expression}'\")\n    print(f\"Starting from: {start_from}\")\n    print(f\"Next occurrence: {cron_iterator.get_next(datetime)}\")\n    print(f\"Second next occurrence: {cron_iterator.get_next(datetime)}\")\n\nif __name__ == \"__main__\":\n    current_time = datetime(2026, 4, 6, 10, 30)\n    schedule_info('0 0 * * *', current_time) # Daily at midnight\n    print(\"-\" * 20)\n    schedule_info('*/15 * * * *', current_time) # Every 15 minutes","lang":"python","description":"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."},"warnings":[{"fix":"Ensure that the `types-croniter` package version aligns with the installed `croniter` package version, typically by pinning the major.minor.patch versions. Regularly update both packages.","message":"Version mismatches between `types-croniter` and the `croniter` runtime library can lead to incorrect or incomplete type checking results. The `types-croniter` version typically reflects the `croniter` version it targets (e.g., `types-croniter==6.2.2.YYYYMMDD` targets `croniter==6.2.2`).","severity":"gotcha","affected_versions":"<6.2.2.20260402"},{"fix":"Always install the `croniter` package (`pip install croniter`) in addition to `types-croniter` if you intend to run the code.","message":"`types-croniter` is a stub-only package and does not include the actual `croniter` runtime code. Installing `types-croniter` alone will not provide the `croniter` functionality.","severity":"breaking","affected_versions":"All versions"},{"fix":"Explicitly install `types-croniter` using `pip install types-croniter`. MyPy might suggest the correct installation command in its error message. You can also run `mypy --install-types`.","message":"For MyPy versions 0.900 and later, third-party stub packages like `types-croniter` must be explicitly installed. They are no longer bundled with MyPy. Failing to install them will result in 'Missing imports' or 'Library stubs not installed' errors.","severity":"gotcha","affected_versions":"mypy>=0.900"},{"fix":"Pin your stub package versions in your `requirements.txt` or `pyproject.toml` to the versions that are compatible with your codebase and type checker. Review typeshed's changelog for significant changes when upgrading.","message":"While `typeshed` aims to minimize breaking changes, updates to stub packages can sometimes introduce changes that cause type checking to fail, even if the underlying runtime library has not changed. This is due to evolving type system features or more precise annotations.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-06T00:00:00.000Z","next_check":"2026-07-05T00:00:00.000Z"}