diff --git a/bson/codec_options.py b/bson/codec_options.py index add5416a5b..569ac55026 100644 --- a/bson/codec_options.py +++ b/bson/codec_options.py @@ -273,9 +273,6 @@ def with_options(self, **kwargs: Any) -> CodecOptions[Any]: def _arguments_repr(self) -> str: ... - def _options_dict(self) -> dict[Any, Any]: - ... - # NamedTuple API @classmethod def _make(cls, obj: Iterable[Any]) -> CodecOptions[_DocumentType]: @@ -466,19 +463,6 @@ def _arguments_repr(self) -> str: ) ) - def _options_dict(self) -> dict[str, Any]: - """Dictionary of the arguments used to create this object.""" - # TODO: PYTHON-2442 use _asdict() instead - return { - "document_class": self.document_class, - "tz_aware": self.tz_aware, - "uuid_representation": self.uuid_representation, - "unicode_decode_error_handler": self.unicode_decode_error_handler, - "tzinfo": self.tzinfo, - "type_registry": self.type_registry, - "datetime_conversion": self.datetime_conversion, - } - def __repr__(self) -> str: return f"{self.__class__.__name__}({self._arguments_repr()})" @@ -494,7 +478,7 @@ def with_options(self, **kwargs: Any) -> CodecOptions: .. versionadded:: 3.5 """ - opts = self._options_dict() + opts = self._asdict() opts.update(kwargs) return CodecOptions(**opts) diff --git a/bson/json_util.py b/bson/json_util.py index 8151226a26..0b59c406dd 100644 --- a/bson/json_util.py +++ b/bson/json_util.py @@ -382,19 +382,6 @@ def _arguments_repr(self) -> str: ) ) - def _options_dict(self) -> dict[Any, Any]: - # TODO: PYTHON-2442 use _asdict() instead - options_dict = super()._options_dict() - options_dict.update( - { - "strict_number_long": self.strict_number_long, - "datetime_representation": self.datetime_representation, - "strict_uuid": self.strict_uuid, - "json_mode": self.json_mode, - } - ) - return options_dict - def with_options(self, **kwargs: Any) -> JSONOptions: """ Make a copy of this JSONOptions, overriding some options:: @@ -408,7 +395,7 @@ def with_options(self, **kwargs: Any) -> JSONOptions: .. versionadded:: 3.12 """ - opts = self._options_dict() + opts = self._asdict() for opt in ("strict_number_long", "datetime_representation", "strict_uuid", "json_mode"): opts[opt] = kwargs.get(opt, getattr(self, opt)) opts.update(kwargs)