{"id":8736,"library":"types-atomicwrites","title":"Typing stubs for atomicwrites","description":"types-atomicwrites is a PEP 561 type stub package for the atomicwrites library, currently at version 1.4.5.1. It provides type annotations for use by static type checkers like MyPy and PyCharm. While it is part of the broader typeshed project, this specific stub package is explicitly noted as unmaintained and will not be updated. Furthermore, the underlying atomicwrites library itself has been marked as deprecated by its original maintainer, who recommends using Python 3's built-in os.replace or os.rename functions for most atomic file writing needs.","status":"deprecated","version":"1.4.5.1","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","type hints","atomic writes","typeshed"],"install":[{"cmd":"pip install types-atomicwrites","lang":"bash","label":"Install stubs"},{"cmd":"pip install atomicwrites","lang":"bash","label":"Install runtime library (required)"}],"dependencies":[{"reason":"Provides the runtime functionality for which these stubs are provided.","package":"atomicwrites","optional":false}],"imports":[{"note":"types-atomicwrites provides type hints for the atomicwrites package; you import from the runtime package, not the stub package itself.","wrong":"from types_atomicwrites import atomic_write","symbol":"atomic_write","correct":"from atomicwrites import atomic_write"},{"note":"The lower-level class for more control over atomic writes.","symbol":"AtomicWriter","correct":"from atomicwrites import AtomicWriter"}],"quickstart":{"code":"from atomicwrites import atomic_write\n\ndef save_data_atomically(filename: str, content: str):\n    try:\n        with atomic_write(filename, overwrite=True) as f:\n            f.write(content)\n        print(f\"Successfully wrote to {filename}\")\n    except Exception as e:\n        print(f\"Error writing to {filename}: {e}\")\n\n# Example usage:\nsave_data_atomically(\"my_config.txt\", \"config_key=value\\nother_setting=123\")\n","lang":"python","description":"This quickstart demonstrates how to perform an atomic file write using the `atomicwrites` library. Installing `types-atomicwrites` alongside `atomicwrites` will enable static type checking for this code."},"warnings":[{"fix":"Consider migrating to `os.replace` or `os.rename` for atomic operations, or another actively maintained atomic writing library. Alternatively, pin `atomicwrites` to a version compatible with the latest stubs (e.g., `atomicwrites==1.4.0`) to avoid type-checking discrepancies.","message":"The `types-atomicwrites` package is officially unmaintained and will not receive further updates. This means future versions of `atomicwrites` may not have corresponding, accurate type stubs, potentially leading to incorrect type checking results or runtime errors if type-checked code relies on outdated signatures.","severity":"breaking","affected_versions":"All versions after 1.4.5.1"},{"fix":"For new projects, prefer Python's built-in `os.replace` or `os.rename` functions for atomic file writes. For existing projects, evaluate migration away from `atomicwrites` to these standard library functions or an actively maintained alternative.","message":"The upstream `atomicwrites` library itself is considered deprecated by its original maintainer, who advises using `os.replace` or `os.rename` for atomic file operations in Python 3. This deprecation stems from issues including PyPI's 2FA requirements and the maintainer's decision not to continue maintenance.","severity":"deprecated","affected_versions":"All versions of `atomicwrites`"},{"fix":"Ensure that the temporary file and the target file reside on the same filesystem. For critical applications, thoroughly test atomicity guarantees on target deployment platforms and consider additional layers of data validation or recovery.","message":"`atomicwrites` (and thus code relying on its stubs) may not be truly atomic in all scenarios, especially on Windows or when files are moved across different filesystems. This can lead to data corruption or unexpected states in case of system failure.","severity":"gotcha","affected_versions":"All versions of `atomicwrites`"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the runtime library: `pip install atomicwrites`.","cause":"`types-atomicwrites` only provides type hints and does not include the runtime code for the `atomicwrites` library itself. The actual `atomicwrites` package is missing.","error":"ModuleNotFoundError: No module named 'atomicwrites'"},{"fix":"Downgrade `atomicwrites` to a version compatible with `types-atomicwrites==1.4.5.1` (which corresponds to `atomicwrites==1.4.*`), or consider migrating to `os.replace`/`os.rename` or an alternative atomic writing library.","cause":"The `types-atomicwrites` stub package is unmaintained and may be out of sync with newer versions of the `atomicwrites` library, leading to inaccurate type hints or incompatible signatures.","error":"Type checker errors (e.g., error: Missing type parameters for generic type \"AtomicWriter\") or unexpected runtime behavior when using `atomicwrites` features."},{"fix":"Ensure `atomicwrites` is pinned to a specific, known-good version (e.g., `atomicwrites==1.4.0`) in your `requirements.txt` or `pyproject.toml` to avoid unexpected dependency resolution failures. Given its unmaintained status, consider migrating away from `atomicwrites`.","cause":"The `atomicwrites` package experienced a temporary deletion of old versions from PyPI due to maintainer issues, which, despite being restored, indicates potential instability.","error":"CI/CD pipeline failures related to `atomicwrites` dependency resolution (e.g., specific versions not found)."}]}