{"id":10325,"library":"types-vobject","title":"Typing Stubs for vobject","description":"The `types-vobject` library provides type annotations (stubs) for the `vobject` library, enabling static type checkers like MyPy or Pyright to analyze code that uses `vobject` for potential type-related errors. It does not provide any runtime functionality itself. As part of the `typeshed` project, it is frequently updated to reflect changes in `vobject` and improvements in typing quality. The current version is 0.9.9.20260408.","status":"active","version":"0.9.9.20260408","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","vobject","typeshed","icalendar","vcard"],"install":[{"cmd":"pip install types-vobject","lang":"bash","label":"Install only stubs"},{"cmd":"pip install vobject types-vobject","lang":"bash","label":"Install library and stubs"}],"dependencies":[{"reason":"The stubs are useless without the actual `vobject` library installed for runtime execution.","package":"vobject","optional":true}],"imports":[{"note":"`types-vobject` provides stubs, not runtime modules. Imports should always be from the `vobject` package.","wrong":"from types_vobject import Component","symbol":"Component","correct":"import vobject\nfrom vobject.base import Component"},{"note":"Never import directly from `types_vobject`.","wrong":"import types_vobject.base.VEvent","symbol":"VEvent","correct":"from vobject.base import VEvent"}],"quickstart":{"code":"import vobject\nfrom vobject.base import Component, VEvent\nfrom typing import cast, List\n\n# Install 'vobject' and 'types-vobject' first:\n# pip install vobject types-vobject\n\ndef create_simple_calendar() -> Component:\n    \"\"\"Creates a VCALENDAR with a single VEVENT using type hints.\"\"\"\n    # 'calendar' is inferred as vobject.base.Component\n    calendar = vobject.newFromBehavior('vcalendar')\n\n    # Add an event component\n    event: Component = calendar.add('vevent')\n\n    # Accessing the event via vevent_list is type-safe due to stubs\n    event_list: List[VEvent] = calendar.vevent_list\n    first_event = event_list[0] # first_event is inferred as VEvent\n\n    first_event.add('dtstart').value = '20231027T100000'\n    first_event.add('dtend').value = '20231027T110000'\n    first_event.add('summary').value = 'Meeting with client'\n    first_event.add('description').value = 'Discuss project roadmap and next steps.'\n\n    return calendar\n\nif __name__ == '__main__':\n    my_calendar = create_simple_calendar()\n    print(my_calendar.serialize())\n\n    # Accessing properties with type safety\n    first_event: VEvent = my_calendar.vevent_list[0]\n    print(f\"\\nEvent Summary: {first_event.summary.value}\")\n    print(f\"Event Description: {first_event.description.value}\")\n    print(f\"Event Start: {first_event.dtstart.value}\")\n","lang":"python","description":"This quickstart demonstrates how to use the `vobject` library with type hints. It shows creating a simple VCALENDAR with an event, adding properties, and serializing it. With `types-vobject` installed, a type checker will provide autocompletion and error checking for `vobject` objects and methods."},"warnings":[{"fix":"Always install `vobject` (e.g., `pip install vobject`) alongside `types-vobject` if you intend to run the code.","message":"Installing `types-vobject` provides only type annotations for static analysis; it does not add any new runtime objects, functions, or classes to your Python environment. You must install the actual `vobject` library (`pip install vobject`) to use its functionalities.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your `vobject` and `types-vobject` versions are relatively close. If you encounter type checking issues, try upgrading both packages to their latest compatible versions or checking the `typeshed` repository for which `vobject` version the stubs target.","message":"The type stubs provided by `types-vobject` are generated from a specific version of the `vobject` library. Using significantly different versions of `vobject` and `types-vobject` can lead to incorrect type checking results (e.g., missing attributes or incorrect signatures) or even runtime errors if type hints mislead you.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"The `types-vobject` package contains only stub files (`.pyi`) for type checkers. All imports should be made from the `vobject` library itself (e.g., `import vobject` or `from vobject.base import Component`).","cause":"Attempting to import modules or classes directly from the `types_vobject` package (e.g., `from types_vobject import ...`).","error":"ModuleNotFoundError: No module named 'types_vobject'"},{"fix":"First, ensure `pip install vobject` is run. If `vobject` is installed, verify `vobject` and `types-vobject` versions are compatible. Finally, check your type checker's configuration (e.g., `mypy.ini`) to ensure it's correctly picking up the installed stubs in your virtual environment.","cause":"This error from a type checker (like MyPy or Pyright) indicates that either the `vobject` library itself is not installed, or the installed `types-vobject` stubs are for a significantly different version of `vobject` than what's installed, or the type checker environment is not correctly configured to find the stubs.","error":"error: Module 'vobject' has no attribute '...' (reportAttributeAccessIssue)"},{"fix":"Run `pip install vobject`. Type stubs are only useful if the actual library they describe is also present.","cause":"This type checker error indicates that the `vobject` library itself (not just its stubs) is not installed in the Python environment that the type checker is inspecting.","error":"error: Cannot find module named 'vobject' (reportMissingImports)"}]}