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
45 changes: 31 additions & 14 deletions mirth_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,32 @@
from uuid import UUID

import xmltodict
from pydantic import (
BaseModel,
Protocol,
StrBytes,
ValidationError,
root_validator,
validator,
)
from pydantic.error_wrappers import ErrorWrapper
import typing
import pydantic
from packaging import version

if typing.TYPE_CHECKING or version.parse(pydantic.__version__) >= version.parse("2.0"):
from pydantic.v1 import (
BaseModel,
ValidationError,
root_validator,
validator,
StrBytes,
Protocol,
)
from pydantic.v1.error_wrappers import ErrorWrapper
else:
from pydantic import (
BaseModel,
Protocol,
StrBytes,
ValidationError,
root_validator,
validator,
)
from pydantic.error_wrappers import ErrorWrapper


from typing_extensions import TypedDict

if TYPE_CHECKING:
Expand Down Expand Up @@ -181,7 +198,7 @@ def parse_raw( # pylint: disable=arguments-differ
*,
content_type: Optional[str] = "xml",
encoding: str = "utf8",
proto: Protocol = None,
proto: Optional[Protocol] = None,
allow_pickle: bool = False,
) -> "Model":
"""Parse raw data into a Pydantic object.
Expand Down Expand Up @@ -214,17 +231,17 @@ def parse_raw( # pylint: disable=arguments-differ
raise ValidationError([ErrorWrapper(e, loc="__obj__")], cls) from e
return super().parse_raw( # type: ignore
b,
content_type=content_type,
content_type=content_type, # type: ignore
encoding=encoding,
proto=proto,
proto=proto, # type: ignore
allow_pickle=allow_pickle,
)

def xml(
self,
*,
include: Union["SetIntStr", "DictIntStrAny"] = None,
exclude: Union["SetIntStr", "DictIntStrAny"] = None,
include: Union["SetIntStr", "DictIntStrAny", None] = None,
exclude: Union["SetIntStr", "DictIntStrAny", None] = None,
by_alias: bool = True,
exclude_unset: bool = False,
) -> str:
Expand Down
17 changes: 8 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ packages = [
{include = "mirth_client"},
]
readme = "README.md"
version = "3.2.0"
version = "4.1.0"

[tool.poetry.dependencies]
Sphinx = {version = ">=3.5.3,<6.0.0", optional = true}
httpx = ">=0.23,<0.25"
httpx = ">=0.23,<0.28.1"
pydantic = ">=1.8.2,<3.0.0"
python = "^3.9"
semver = ">=2.13,<4.0"
Expand All @@ -21,17 +21,16 @@ xmltodict = ">=0.12,<0.14"
[tool.poetry.extras]
docs = ["Sphinx", "sphinx-rtd-theme"]

[tool.poetry.dev-dependencies]
bandit = "^1.7.0"
black = "^23.3"
[tool.poetry.group.dev.dependencies]
bandit = "^1.7.0"
importlib-metadata = "<7" # Workaround for https://github.com/PyCQA/bandit/issues/951
isort = "^5.7.0"
lxml = "^5.2.2"
mypy = "^1.1"
pylint = "^2.8.2"
lxml = "^5.2.2"
mypy = "^1.1"
pytest = "^7.0.0"
pytest-cov = "^4.0.0"
tox = "^3.23.0"
tox = "^3.23.0"
ruff = "^0.12.0"

[build-system]
build-backend = "poetry.core.masonry.api"
Expand Down
1 change: 0 additions & 1 deletion tests/_get_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

for path in paths.values():
for method in path.keys():

# Response examples
response_examples_xml = (
path.get(method)
Expand Down
1 change: 0 additions & 1 deletion tests/test_models/test_get_event_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime
from pathlib import Path
from uuid import UUID
from mirth_client.models import EventList

EVENT_LIST_RESPONSE = (
Expand Down
19 changes: 9 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[tox]
isolated_build = true
envlist = black, mypy, pylint, bandit
envlist = ruff-format, mypy, pytest, ruff-lint, bandit

[testenv]
whitelist_externals = poetry
commands =
poetry install -v
allowlist_externals = poetry
commands = poetry install -v --with dev

[testenv:black]
description = 'Check code style with Black'
commands = poetry run black . --check
[testenv:ruff-format]
description = 'Check code style with ruff'
commands = poetry run ruff format . --check

[testenv:pytest]
description = 'Run Python tests with pytest test runner.'
Expand All @@ -19,9 +18,9 @@ commands = poetry run pytest --cov=mirth_client --cov-report term-missing --cov-
description = 'Execute static analysis with mypy (type annotations).'
commands = poetry run mypy mirth_client/

[testenv:pylint]
description = 'Execute static analysis with pylint.'
commands = poetry run pylint mirth_client/
[testenv:ruff-lint]
description = 'Execute static analysis with ruff.'
commands = poetry run ruff check mirth_client/

[testenv:bandit]
description = 'Execute static analysis with bandit.'
Expand Down