Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions bson/codec_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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()})"

Expand All @@ -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)

Expand Down
15 changes: 1 addition & 14 deletions bson/json_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand All @@ -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)
Expand Down
Loading