You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Severity: High. A subclass can accept construction while filelock discards a requested safety policy.
Problem
FileLockMeta._create_instance()
filters constructor arguments by the parameter names present in the subclass __init__ signature.
This supports older subclasses with narrow signatures, but it has two failure modes:
A subclass with **kwargs does not receive base options because VAR_KEYWORD is not a named option.
A narrow subclass discards non-default values such as on_acquired, preserve_lock_file, fallback_to_soft, context_error_policy, and close_error_policy.
Construction succeeds even though the requested behavior is inactive. The metaclass also calls inspect.signature() for
each construction.
Required contract
Pass all supported base options when the subclass accepts **kwargs. For a narrow signature, omit unsupported options
only when the caller supplied the documented default. Raise TypeError for each unsupported non-default option.
Cache the inspected signature and accepted-option model per subclass after the forwarding rules are correct. The cache
must not change singleton argument comparison.
Verification
Define a virtualenv-style subclass with a narrow constructor and confirm that default construction still works.
Pass each non-default base option to that subclass and confirm that construction raises before acquisition.
Define a forwarding subclass with **kwargs and confirm that each option reaches BaseFileLock.
Cover direct subclasses of sync and async base locks.
Confirm that singleton reuse still rejects a changed hook object or policy.
Benchmark repeated construction before and after signature caching with the same interpreter.
Activity
🐛 fix(api): reject dropped lock options (#646)