{"id":3841,"library":"types-dateparser","title":"Typing Stubs for dateparser","description":"types-dateparser is a type stub package that provides external type annotations for the `dateparser` library. It enables static type checkers (like MyPy or Pyright) to analyze code using `dateparser` for type correctness without affecting runtime behavior. The current version, `1.4.0.20260408`, indicates it aims to provide accurate annotations for `dateparser~=1.4.0`, with the last part reflecting the typeshed release date. Updates are frequent, often daily, reflecting typeshed's continuous integration and bug fixes.","status":"active","version":"1.4.0.20260408","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["type hints","typing","stubs","dateparser","static analysis"],"install":[{"cmd":"pip install types-dateparser","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"This package provides typing stubs for the `dateparser` runtime library; `dateparser` must be installed for these stubs to be useful.","package":"dateparser"}],"imports":[{"note":"The `types-dateparser` package provides static type hints for the `dateparser` library. It is not meant for direct import at runtime. Type checkers automatically discover and use these stubs when `dateparser` is imported.","wrong":"from types_dateparser import parse","symbol":"parse","correct":"from dateparser import parse"}],"quickstart":{"code":"import dateparser\nfrom datetime import datetime\n\n# types-dateparser provides type hints for the dateparser library.\n# It is not imported directly for runtime functionality.\n\ndate_string = \"today\"\nparsed_date: datetime | None = dateparser.parse(date_string)\n\nif parsed_date:\n    print(f\"Parsed '{date_string}': {parsed_date}\")\nelse:\n    print(f\"Could not parse '{date_string}'\")\n\n# Example with a specific format and language setting\nfrench_date_string = \"20 Février 2023\"\nparsed_french_date: datetime | None = dateparser.parse(\n    french_date_string, languages=['fr']\n)\nif parsed_french_date:\n    print(f\"Parsed '{french_french_date_string}' (French): {parsed_french_date}\")","lang":"python","description":"This quickstart demonstrates the typical usage of the `dateparser` library, which is enhanced by the `types-dateparser` stubs for static type checking. The stubs themselves are not directly used in the runtime code."},"warnings":[{"fix":"Always import from the `dateparser` package for runtime functionality: `import dateparser` or `from dateparser import parse`.","message":"Do not attempt to import symbols directly from `types_dateparser`. This package is purely for static type analysis and does not contain runtime code. Importing from it will result in `ModuleNotFoundError` or incorrect behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin the `types-dateparser` version to match your `dateparser` dependency's major/minor/patch versions (e.g., `pip install 'dateparser==1.4.0' 'types-dateparser==1.4.0.*'`).","message":"Ensure the `X.Y.Z` part of `types-dateparser`'s version aligns with the installed version of `dateparser`. For example, `types-dateparser==1.4.0.YYYYMMDD` is intended for `dateparser~=1.4.0`. Mismatched versions can lead to inaccurate type checking results, where the stubs describe an API different from your installed runtime library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Rely on your type checker's automatic stub discovery mechanism. Only use explicit path configurations if you are developing stubs or facing specific advanced scenarios.","message":"Explicitly configuring `MYPYPATH` or similar environment variables for `types-dateparser` is usually unnecessary. Modern type checkers automatically discover installed stub packages in your Python environment. Manual configuration can sometimes lead to issues if paths are incorrect or conflict with automatic discovery.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review `dateparser`'s release notes for breaking changes and update your code and type annotations accordingly. Update `types-dateparser` in conjunction with `dateparser` to maintain type accuracy.","message":"As `types-dateparser` reflects the API of `dateparser`, major or even minor breaking changes in `dateparser`'s API will eventually be mirrored in the stubs. This may cause type-checking errors in your project even if `dateparser`'s runtime code still functions due to its internal backward compatibility mechanisms.","severity":"breaking","affected_versions":"Between major versions of `dateparser` (e.g., `dateparser` 1.x to 2.x), and sometimes minor versions."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}