{"id":7827,"library":"types-pyrfc3339","title":"Typing Stubs for pyRFC3339","description":"types-pyrfc3339 provides high-quality static type annotations (typing stubs) for the pyRFC3339 library. pyRFC3339 itself is a Python library that parses and generates RFC 3339-compliant timestamps using Python's `datetime.datetime` objects. This stub package, currently at version 2.0.1.20250825, is automatically generated and released from the community-driven Typeshed repository, typically with daily updates to keep pace with changes in the runtime library.","status":"active","version":"2.0.1.20250825","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","type hints","RFC3339","datetime","typeshed"],"install":[{"cmd":"pip install types-pyrfc3339","lang":"bash","label":"Install typing stubs"}],"dependencies":[{"reason":"This package provides type hints for the pyRFC3339 runtime library. pyRFC3339 must be installed separately for the code to run, as types-pyrfc3339 does not include any runtime functionality.","package":"pyRFC3339","optional":false}],"imports":[{"note":"The `types-pyrfc3339` package provides stubs for `pyrfc3339`. You import directly from the runtime library, `pyrfc3339`, not from the stub package name.","wrong":"from types_pyrfc3339 import generate","symbol":"generate","correct":"from pyrfc3339 import generate"},{"note":"The `types-pyrfc3339` package provides stubs for `pyrfc3339`. You import directly from the runtime library, `pyrfc3339`, not from the stub package name.","wrong":"from types_pyrfc3339 import parse","symbol":"parse","correct":"from pyrfc3339 import parse"}],"quickstart":{"code":"import datetime\nfrom pyrfc3339 import generate, parse\n\n# Get current UTC time to generate an RFC 3339 timestamp\nnow_utc = datetime.datetime.now(datetime.timezone.utc)\nprint(f\"Current UTC datetime: {now_utc.isoformat()}\")\n\n# Generate RFC 3339 timestamp string\nrfc3339_string = generate(now_utc)\nprint(f\"Generated RFC 3339 string: {rfc3339_string}\")\n\n# Parse an RFC 3339 timestamp string back to a datetime object\nsome_rfc3339_string = \"2023-10-27T10:30:00.123456Z\"\nparsed_dt = parse(some_rfc3339_string)\nprint(f\"Parsed RFC 3339 string: {parsed_dt}\")\n\n# The presence of types-pyrfc3339 allows type checkers (e.g., Mypy) to validate arguments:\n# For example, uncommenting the line below would trigger a type error:\n# generate(\"not a datetime object\")","lang":"python","description":"This quickstart demonstrates basic usage of the `pyrfc3339` library for generating and parsing RFC 3339 timestamps. With `types-pyrfc3339` installed, a static type checker can verify the correctness of the types used in these operations, catching potential errors before runtime."},"warnings":[{"fix":"Ensure both `pip install pyrfc3339` and `pip install types-pyrfc3339` are run. The stub package alone provides no runnable code.","message":"Installing `types-pyrfc3339` does not install the `pyRFC3339` runtime library itself. You must install `pyRFC3339` separately for your code to execute. `types-pyrfc3339` only provides type information.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For critical projects, consider pinning both `pyRFC3339` and `types-pyrfc3339` to compatible versions. Regularly update both packages and re-run your type checker.","message":"Version mismatches between `types-pyrfc3339` and `pyRFC3339` can lead to inaccurate type checking. Typeshed stubs are frequently updated, sometimes daily, and may reflect newer versions of the runtime library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `from pyrfc3339 import generate, parse` (or other symbols) for runtime code. The `types-*` prefix is an installation convention, not an import path.","message":"Do not attempt to import symbols directly from `types_pyrfc3339`. The stub package's name on PyPI (`types-pyrfc3339`) is for installation purposes only. Runtime imports should always be from the actual library: `from pyrfc3339 import ...`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install pyrfc3339` to install the actual library that provides the functions.","cause":"The `pyRFC3339` runtime library is not installed, even though `types-pyrfc3339` might be.","error":"ModuleNotFoundError: No module named 'pyrfc3339'"},{"fix":"Ensure the arguments passed to `pyrfc3339.generate` and `pyrfc3339.parse` match the expected types (e.g., `datetime.datetime` for `generate`, `str` for `parse`).","cause":"You are passing an incorrect type (e.g., `str`) to a function that expects a `datetime.datetime` object, as enforced by the `types-pyrfc3339` stubs.","error":"mypy: Argument 1 to \"generate\" has incompatible type \"str\"; expected \"datetime.datetime\""}]}