Registry / type-stubs / types-filelock

types-filelock

JSON →
library3.2.7pypypi✓ verified 22d ago

This package provides static type checking stubs for the `filelock` library, enabling tools like MyPy to verify type correctness. It is part of the Python typeshed project, which maintains high-quality stubs generally kept up-to-date with the latest versions of their respective runtime libraries. Releases follow typeshed's continuous integration and release cycle, reflecting updates to the underlying `filelock` library.

pip install types-filelock
INSTALL
IMPORT
SIG · TYPES-FILELOCK
T
types-filelock
type-stubspythonv3.2.7
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.2.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FileLock
from filelock_stubs import FileLock
from filelock-stubs import FileLock

This quickstart demonstrates the usage of the `filelock` library, for which `types-filelock` provides type hints. To run this code with type checking, ensure both `filelock` and `types-filelock` are installed. The `FileLock` context manager ensures that the enclosed code block is executed exclusively, preventing race conditions across processes.

import os import time from filelock import FileLock # Define a lock file path lock_file_path = "/tmp/my_app.lock" try: # Acquire the lock. If another process holds it, this will block until it's released. # The timeout parameter ensures it doesn't wait indefinitely. with FileLock(lock_file_path, timeout=5): print("Lock acquired. Performing exclusive operation...") # Simulate work time.sleep(2) print("Exclusive operation completed. Releasing lock.") except Exception as e: print(f"Could not acquire lock or an error occurred: {e}")
Debug
Known issues
gotchaInstalling `types-filelock` does NOT install the `filelock` runtime library. You must install `filelock` separately (e.g., `pip install filelock`) for your code to function.
fix
Ensure `filelock` is listed in your project's dependencies and installed alongside `types-filelock`.
affects: All versions
gotchaDo not attempt to import symbols directly from `types_filelock` (or any variation of the stub package name). The purpose of `types-filelock` is to provide type information for imports from the original `filelock` library.
fix
Always import symbols directly from the `filelock` package, e.g., `from filelock import FileLock`.
affects: All versions
gotchaType stubs are maintained by the typeshed project and may occasionally lag behind the absolute latest releases of the `filelock` library. This can lead to `mypy` errors if `filelock` introduces new features or changes its API before corresponding stubs are updated.
fix
If encountering type errors due to new `filelock` features, consider pinning `filelock` to an older version until stubs are updated, or temporarily ignoring specific `mypy` errors.
affects: All versions
Upgrade
Version history
3.2.7latest on PyPI · released Jun 9, 2022
Audit
Dependencies
filelockrequiredProvides the runtime functionality for which these stubs offer type hints. Must be installed separately.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
types-filelock — pip install types-filelock · libregistry