MCPcopy Create free account
hub / github.com/tox-dev/filelock / _create_instance

Method _create_instance

src/filelock/_api.py:448–468  ·  view source on GitHub ↗
(
        cls: type[_T], lock_file: str | os.PathLike[str], params: dict[str, _LockInitValue | _ExtraValue]
    )

Source from the content-addressed store, hash-verified

446 raise ValueError(msg)
447
448 def _create_instance(
449 cls: type[_T], lock_file: str | os.PathLike[str], params: dict[str, _LockInitValue | _ExtraValue]
450 ) -> _T:
451 model = _init_parameter_model(cls)
452 if model.accepts_kwargs:
453 return super().__call__(lock_file, **params)
454
455 unsupported = sorted(
456 name
457 for name, value in params.items()
458 if name not in model.accepted_params
459 and ((parameter := model.default_params.get(name)) is None or value != parameter.default)
460 )
461 if unsupported:
462 msg = f"{cls.__name__} does not support non-default lock options: {', '.join(unsupported)}"
463 raise TypeError(msg)
464 # virtualenv narrows a BaseFileLock descendant's signature; omit base defaults it does not accept (#340).
465 return super().__call__(
466 lock_file,
467 **{name: value for name, value in params.items() if name in model.accepted_params},
468 )
469
470
471_INIT_PARAMETER_MODELS: Final[WeakKeyDictionary[type[BaseFileLock], _InitParameterModel]] = WeakKeyDictionary()

Callers 1

__call__Method · 0.80

Calls 3

_init_parameter_modelFunction · 0.85
joinMethod · 0.80
__call__Method · 0.45

Tested by

no test coverage detected