{"id":7819,"library":"types-appdirs","title":"types-appdirs (Type Stubs for appdirs)","description":"types-appdirs is a PEP 561 type stub package providing static type checking information for the 'appdirs' library. It enables type-checking tools like Mypy and Pyright to analyze code using 'appdirs'. The package is currently at version 1.4.3.5 (released March 14, 2023). This package is unmaintained and deprecated; users are encouraged to migrate to 'platformdirs', which includes its own type information.","status":"deprecated","version":"1.4.3.5","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed/tree/main/stubs/appdirs","tags":["type-stubs","appdirs","mypy","type-checking","deprecated","platformdirs","utility","filesystem"],"install":[{"cmd":"pip install types-appdirs","lang":"bash","label":"Install types-appdirs"},{"cmd":"pip install appdirs","lang":"bash","label":"Install runtime dependency (appdirs)"}],"dependencies":[{"reason":"Provides runtime functionality; types-appdirs only provides 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"},{"note":"types-appdirs provides stubs for the appdirs library, so you import from 'appdirs' directly.","wrong":"from types_appdirs import AppDirs","symbol":"AppDirs","correct":"from appdirs import AppDirs"}],"quickstart":{"code":"from appdirs import user_data_dir, user_config_dir, user_cache_dir\nimport os\n\nappname = \"MyAwesomeApp\"\nappauthor = \"MyCompany\"\n\n# Get user-specific data directory\ndata_dir = user_data_dir(appname, appauthor)\nprint(f\"User Data Directory: {data_dir}\")\n\n# Get user-specific configuration directory\nconfig_dir = user_config_dir(appname, appauthor)\nprint(f\"User Config Directory: {config_dir}\")\n\n# Get user-specific cache directory\ncache_dir = user_cache_dir(appname, appauthor, version=\"1.0\")\nprint(f\"User Cache Directory (v1.0): {cache_dir}\")\n\n# Create a directory if it doesn't exist (appdirs does not create paths automatically)\nos.makedirs(data_dir, exist_ok=True)\nprint(f\"Ensured data directory exists: {data_dir}\")","lang":"python","description":"This quickstart demonstrates how to use `appdirs` (for which `types-appdirs` provides stubs) to retrieve common application-specific directory paths for the current user and platform. It also shows how to create one of these directories, as `appdirs` only provides the path strings."},"warnings":[{"fix":"Migrate your application from `appdirs` to `platformdirs`. The API is largely compatible, making migration straightforward. Remove `types-appdirs` after migration.","message":"The `types-appdirs` package is unmaintained and deprecated. The underlying `appdirs` library is also deprecated. Users should migrate to `platformdirs` which is an actively maintained fork and includes its own type information, removing the need for separate stubs.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Correct the keyword argument from `appversion` to `version` when calling `appdirs` functions (e.g., `user_data_dir(appname, appauthor, version='1.0')`).","message":"Functions like `user_data_dir`, `user_config_dir`, etc., in `appdirs` expect the application version argument to be named `version`, not `appversion`. Using `appversion` will result in a `TypeError: unexpected keyword argument`.","severity":"breaking","affected_versions":"appdirs < 1.4.0 (and implicitly types-appdirs for these versions), specifically pre-dating appdirs 1.4.0 where explicit appversion was added. However, the correct argument name is consistently 'version'."},{"fix":"Always verify the generated paths on your target operating systems. If `appdirs`'s default naming is problematic, consider examining the `platformdirs` documentation for more flexible options or implementing custom logic. You can sometimes disable opinionated behavior with `opinion=False` where available (e.g., `user_log_dir`).","message":"`appdirs` is 'slightly opinionated' on directory names. The exact paths generated can sometimes differ from strict system conventions or other tools' interpretations, potentially adding specific suffixes to directory names.","severity":"gotcha","affected_versions":"All versions of appdirs"},{"fix":"Ensure you are using at least `appdirs==1.4.4` for Python 3 environments. For the best compatibility and ongoing support, migrate to `platformdirs`.","message":"Older `appdirs` 1.x releases (e.g., 1.4.1) had specific issues with Python 3, particularly concerning Windows registry access (`winreg`) and string handling. These were addressed in subsequent minor releases.","severity":"gotcha","affected_versions":"appdirs < 1.4.4"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change `appversion=some_version` to `version=some_version` in your function calls. Example: `user_data_dir(appname, appauthor, version='1.0')`.","cause":"Using the keyword argument `appversion` instead of `version` when calling `appdirs` functions (e.g., `user_data_dir`).","error":"TypeError: unexpected keyword argument 'appversion'"},{"fix":"Install the `appdirs` package: `pip install appdirs`.","cause":"The `appdirs` runtime library is not installed. `types-appdirs` only provides type stubs, not the actual implementation.","error":"ModuleNotFoundError: No module named 'appdirs'"},{"fix":"Manually create the directory (and any necessary parent directories) using `os.makedirs(path, exist_ok=True)` before attempting to write files to it.","cause":"The directories returned by `appdirs` functions are just strings representing paths; `appdirs` does not create these directories on the filesystem automatically.","error":"PathNotFoundException (or similar OS error) when trying to write to an appdirs path."}]}