MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / setdefault

Method setdefault

lib/sqlalchemy/ext/associationproxy.py:1757–1767  ·  view source on GitHub ↗
(self, key: _KT, default: Optional[_VT] = None)

Source from the content-addressed store, hash-verified

1755 return default
1756
1757 def setdefault(self, key: _KT, default: Optional[_VT] = None) -> _VT:
1758 # TODO: again, no idea how to create an actual MutableMapping.
1759 # default must allow None, return type can't include None,
1760 # the stub explicitly allows for default of None with a cryptic message
1761 # "This overload should be allowed only if the value type is
1762 # compatible with None.".
1763 if key not in self.col:
1764 self.col[key] = self._create(key, default)
1765 return default # type: ignore
1766 else:
1767 return self[key]
1768
1769 def keys(self) -> KeysView[_KT]:
1770 return self.col.keys()

Callers

nothing calls this directly

Calls 1

_createMethod · 0.95

Tested by

no test coverage detected