Info about a driver wrapping PyMongo. The MongoDB server logs PyMongo's name, version, and platform whenever PyMongo establishes a connection. A driver implemented on top of PyMongo can add its own info to this log message. Initialize with three strings like 'MyDriver', '1.2.3', 'so
| 23 | |
| 24 | |
| 25 | class DriverInfo(namedtuple("DriverInfo", ["name", "version", "platform"])): |
| 26 | """Info about a driver wrapping PyMongo. |
| 27 | |
| 28 | The MongoDB server logs PyMongo's name, version, and platform whenever |
| 29 | PyMongo establishes a connection. A driver implemented on top of PyMongo |
| 30 | can add its own info to this log message. Initialize with three strings |
| 31 | like 'MyDriver', '1.2.3', 'some platform info'. Any of these strings may be |
| 32 | None to accept PyMongo's default. |
| 33 | """ |
| 34 | |
| 35 | def __new__( |
| 36 | cls, name: str, version: Optional[str] = None, platform: Optional[str] = None |
| 37 | ) -> DriverInfo: |
| 38 | self = super().__new__(cls, name, version, platform) |
| 39 | for key, value in self._asdict().items(): |
| 40 | if value is not None and not isinstance(value, str): |
| 41 | raise TypeError( |
| 42 | f"Wrong type for DriverInfo {key} option, value must be an instance of str, not {type(value)}" |
| 43 | ) |
| 44 | |
| 45 | return self |
no outgoing calls