{"id":7938,"library":"appdirs-stubs","title":"appdirs-stubs","description":"Type stubs for the `appdirs` library, providing static type checking support for code using `appdirs`. This helps tools like MyPy, PyRight, and PyCharm analyze `appdirs` usage. While `appdirs-stubs` is currently maintained (latest version 0.2.0, released Jan 10, 2026), the underlying `appdirs` library has been officially deprecated since 2020 in favor of `platformdirs`.","status":"maintenance","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/repo-helper/appdirs-stubs","tags":["types","stubs","typing","appdirs","platformdirs","type-checking"],"install":[{"cmd":"pip install appdirs-stubs","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Runtime library for which these are type stubs.","package":"appdirs","optional":false}],"imports":[{"symbol":"user_data_dir","correct":"from appdirs import user_data_dir"},{"symbol":"user_config_dir","correct":"from appdirs import user_config_dir"},{"symbol":"user_cache_dir","correct":"from appdirs import user_cache_dir"},{"symbol":"site_data_dir","correct":"from appdirs import site_data_dir"},{"symbol":"site_config_dir","correct":"from appdirs import site_config_dir"},{"symbol":"user_log_dir","correct":"from appdirs import user_log_dir"},{"note":"Class-based access to appdir functions.","symbol":"AppDirs","correct":"from appdirs import AppDirs"}],"quickstart":{"code":"from appdirs import user_data_dir\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    # This block is only for type checkers and helps verify stub correctness\n    appname: str = \"MyApplication\"\n    appauthor: str = \"MyCompany\"\n    data_path: str = user_data_dir(appname, appauthor)\n    # Example: Check if the return type is str\n    reveal_type(data_path)\n\n# Runtime usage of appdirs (requires 'appdirs' package installed)\napp_name_runtime = \"MyAwesomeApp\"\napp_author_runtime = \"CoolDevs\"\nruntime_data_path = user_data_dir(app_name_runtime, app_author_runtime)\nprint(f\"User data directory: {runtime_data_path}\")","lang":"python","description":"Demonstrates importing and using `appdirs` functions with type hints, including an `if TYPE_CHECKING` block to illustrate type-checking functionality with the stubs."},"warnings":[{"fix":"Migrate your application's directory logic from `appdirs` to `platformdirs`. Uninstall `appdirs-stubs` and `appdirs`, then `pip install platformdirs`.","message":"The underlying `appdirs` library is officially deprecated since 2020. Users are strongly encouraged to migrate to `platformdirs` which is a more active fork and includes its own `py.typed` file for type hinting out-of-the-box, eliminating the need for separate stub packages.","severity":"breaking","affected_versions":"<=1.4.4 (for appdirs)"},{"fix":"Transition to `platformdirs` as the primary solution for platform-specific directory needs and its built-in type information. This removes reliance on external stub packages for `appdirs`.","message":"The official `types-appdirs` package from Typeshed is unmaintained and will not receive further updates or fixes for type issues or new features in `appdirs`. While `appdirs-stubs` is a separate, maintained alternative, its utility is limited by the deprecation of `appdirs` itself.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Thoroughly test your application's directory path resolution on all target operating systems and configurations. Consult the `appdirs` (or `platformdirs`) documentation for detailed path behaviors.","message":"The `appdirs` functions (e.g., `user_data_dir`) can return different paths depending on the operating system, presence of environment variables (like XDG spec on Unix), and arguments like `appname`, `appauthor`, `version`, and `roaming`. This behavior is at runtime and not typically caught by type checkers.","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":"Check if an update to `appdirs-stubs` is available (`pip install --upgrade appdirs-stubs`). If not, consider migrating to `platformdirs` which is actively maintained and ships with its own types. Alternatively, use a `# type: ignore` comment if the missing stub is not critical for your type checks.","cause":"The `appdirs` library was updated with a new function or attribute, but `appdirs-stubs` has not yet been updated to reflect these changes. This is more likely now given the deprecation of `appdirs`.","error":"Module 'appdirs' has no attribute 'some_new_function_or_attribute'"},{"fix":"Install the `appdirs-stubs` package: `pip install appdirs-stubs`. If you are using `platformdirs` instead of `appdirs`, ensure `appdirs` is uninstalled.","cause":"This error typically occurs if `appdirs` is installed but `appdirs-stubs` is not, and your type checker is configured to report missing type stubs.","error":"error: Library 'appdirs' has no type annotations or stubs (reportMissingTypeStubs)"}]}