Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the warning log with a warnings.warn instead. #138

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Replace the warning log with a warnings.warn instead.
janwijbrand committed Sep 28, 2023
commit 9919726e265d334c63103beb38ae14faf5105292
17 changes: 13 additions & 4 deletions fhir/resources/core/fhirabstractmodel.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import logging
import pathlib
import typing
import warnings
from collections import OrderedDict
from enum import Enum
from functools import lru_cache
@@ -358,10 +359,14 @@ def json( # type: ignore
option |= orjson.OPT_SORT_KEYS

if len(dumps_kwargs) > 0:
logger.debug(
# NOTE We will warn about the use of extra parameters passed
# into the `json()` call. However, this will only show once as
# it is likely it is the underlying application framework that
# is calling this function.
warnings.warn(
"When ``dumps`` method is used from ``orjson`` "
"all dumps kwargs are ignored except `indent`, `sort_keys` "
"and of course ``option`` from orjson"
"and of course ``option`` from orjson", stacklevel=2
)
dumps_kwargs = {}

@@ -411,11 +416,15 @@ def dict(
& https://github.com/nazrulworld/fhir.resources/issues/89
"""
if len(pydantic_extra) > 0:
logger.warning(
# NOTE We will warn about the use of extra parameters passed
# into the `dict()` call. However, this will only show once as
# it is likely it is the underlying application framework that
# is calling this function.
warnings.warn(
f"{self.__class__.__name__}.dict method accepts only"
"´by_alias´, ´exclude_none´, ´exclude_comments` as parameters"
" since version v6.2.0, any extra parameter is simply ignored. "
"You should not provide any extra argument."
"You should not provide any extra argument.", stacklevel=2
)
return OrderedDict(
self._fhir_iter(